File tree Expand file tree Collapse file tree 1 file changed +47
-0
lines changed
Expand file tree Collapse file tree 1 file changed +47
-0
lines changed Original file line number Diff line number Diff line change 1+ import math
2+
3+ # Function to calculate sum of divisors
4+ def getSum(n) :
5+ sum = 0
6+
7+ # Note that this loop runs till square root
8+ # of n
9+ i = 1
10+ while i <= (math.sqrt(n)) :
11+ if n%i == 0 :
12+
13+ # If divisors are equal,take only one
14+ # of them
15+ if n/i == i :
16+ sum = sum + i
17+ else : # Otherwise take both
18+ sum = sum + i
19+ sum = sum + (n / i )
20+ i = i + 1
21+
22+ # calculate sum of all proper divisors only
23+ sum = sum - n
24+ return sum
25+
26+ # Function to check Abundant Number
27+ def checkAbundant(n) :
28+
29+ # Return true if sum of divisors is greater
30+ # than n.
31+ if (getSum(n) > n) :
32+ return 1
33+ else :
34+ return 0
35+
36+ # Driver program to test above function */
37+ if(checkAbundant(12) == 1) :
38+ print "YES"
39+ else :
40+ print "NO"
41+
42+ if(checkAbundant(15) == 1) :
43+ print "YES"
44+ else :
45+ print "NO"
46+
47+ # This code is contributed by Nikita Tiwari.
You can’t perform that action at this time.
0 commit comments