author | Puneeth Chaganti <punchagan@fossee.in> |
Tue, 12 Jan 2010 19:03:34 +0530 | |
changeset 354 | 5dc6c3673f9d |
parent 94 | 8c92864c184b |
child 380 | 669b72283b55 |
permissions | -rw-r--r-- |
94
8c92864c184b
Almost last set of official solutions and final quiz.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
64
diff
changeset
|
1 |
|
64
333092b68926
Added quiz tex file and all exercise problems Madhu worked out.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
2 |
def aliquot(n): |
94
8c92864c184b
Almost last set of official solutions and final quiz.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
64
diff
changeset
|
3 |
sum = 1 |
8c92864c184b
Almost last set of official solutions and final quiz.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
64
diff
changeset
|
4 |
i = 2 |
8c92864c184b
Almost last set of official solutions and final quiz.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
64
diff
changeset
|
5 |
|
354
5dc6c3673f9d
Changes made during REC Chennai workshop.
Puneeth Chaganti <punchagan@fossee.in>
parents:
94
diff
changeset
|
6 |
while i * i < n: |
64
333092b68926
Added quiz tex file and all exercise problems Madhu worked out.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
7 |
if n % i == 0: |
94
8c92864c184b
Almost last set of official solutions and final quiz.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
64
diff
changeset
|
8 |
sum += i + (n / i) |
8c92864c184b
Almost last set of official solutions and final quiz.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
64
diff
changeset
|
9 |
i += 1 |
354
5dc6c3673f9d
Changes made during REC Chennai workshop.
Puneeth Chaganti <punchagan@fossee.in>
parents:
94
diff
changeset
|
10 |
if n % i == 0: sum += i |
64
333092b68926
Added quiz tex file and all exercise problems Madhu worked out.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
11 |
return sum |
333092b68926
Added quiz tex file and all exercise problems Madhu worked out.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
12 |
|
94
8c92864c184b
Almost last set of official solutions and final quiz.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
64
diff
changeset
|
13 |
n = int(raw_input('Enter a number? ')) |
8c92864c184b
Almost last set of official solutions and final quiz.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
64
diff
changeset
|
14 |
print aliquot(n) |