Skip to content
Open

Code #259

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 8 additions & 12 deletions Largest of the three numbers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,11 @@


# Take the input from the user
num1 = float(input("Enter the first number - "))
num2 = float(input("Enter the second number - "))
num3 = float(input("Enter the third number - "))

if(num1 >= num2) and (num1 >= num3):
largest = num1
elif(num2 >= num3) and (num2 >= num1):
largest = num2
else:
largest = num3

print("The largest number is", largest)
def maximum(a, b, c):
list = [a, b, c]
return max(list)

a = float(input("Enter the first number - "))
b = float(input("Enter the second number - "))
c = float(input("Enter the third number - "))
print(maximum(a, b, c))
46 changes: 18 additions & 28 deletions sum-of-divisors.py
Original file line number Diff line number Diff line change
@@ -1,30 +1,20 @@
"""
Python program to find sum of divisors of a number n,
for example:
print(sum_divisors(0))
# 0
print(sum_divisors(3))
# Should sum of 1
# 1
print(sum_divisors(36))
# Should sum of 1+2+3+4+6+9+12+18
# 55
print(sum_divisors(102))
# Should be sum of 2+3+6+17+34+51
# 114
"""


def sum_divisors(n):
sum = 0
x = 1
while x < n:
if n % x == 0:
sum += x
else:
x += 1

return sum

import math

def divSum(num) :

result = 0

i = 2
while i<= (math.sqrt(num)) :

if (num % i == 0) :

if (i == (num / i)) :
result = result + i;
else :
result = result + (i + num/i);
i = i + 1

return (result + 1);
num = 102
print (divSum(num))