author | Santosh G. Vattam <vattam.santosh@gmail.com> |
Tue, 02 Mar 2010 10:55:49 +0530 | |
changeset 374 | 0ba81871dae5 |
parent 354 | 5dc6c3673f9d |
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) |