forked from seeditsolution/pythonprogram
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDeficientNum
More file actions
39 lines (32 loc) · 765 Bytes
/
DeficientNum
File metadata and controls
39 lines (32 loc) · 765 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import math
# Function to calculate sum of divisors
def divisorsSum(n) :
sum = 0 # Initialize sum of prime factors
# Note that this loop runs till square
# root of n
i = 1
while i<= math.sqrt(n) :
if (n % i == 0) :
# If divisors are equal, take only one
# of them
if (n / i == i) :
sum = sum + i
else : # Otherwise take both
sum = sum + i;
sum = sum + (n / i)
i = i + 1
return sum
# Function to check Deficient Number
def isDeficient(n) :
# Check if sum(n) < 2 * n
return (divisorsSum(n) < (2 * n))
# Driver program to test above function
if ( isDeficient(12) ):
print "YES"
else :
print "NO"
if ( isDeficient(15) ) :
print "YES"
else :
print "NO"
# This Code is contributed by Nikita Tiwari