1)There are four Mobile Phones in a house. At 5 a.m, all the four Mobile Phones will ring together. Thereafter, the first one rings every 15 minutes, the second one rings every 20 minutes, the third one rings every 25 minutes and the fourth one rings every 30 minutes. At what time, will the four Mobile Phones ring together again?
def find_lcm(num1, num2, num3, num4):
lcm = num1
while True:
if lcm % num1 == 0 and lcm % num2 == 0 and lcm % num3 == 0 and lcm % num4 == 0:
return lcm
lcm +=1
num1 = 15
num2 = 20
num3 = 25
num4 = 30
result = find_lcm(num1, num2, num3, num4)
print(result)
o/p:
300
2)A book seller has 175 English books, 245 Science books and 385 Mathematics books. He wants to sell the books in a box, subject-wise in equal numbers. What will be the greatest number of the boxes required? Also find the number of books for each subject in a box.
def find_hcf(num1, num2, num3):
div = 1
hcf = 1
while div <= num1:
if num1 % div == 0 and num2 % div == 0 and num3 % div == 0:
hcf = div
div +=1
return hcf
num1 = 175
num2 = 245
num3 = 385
result = find_hcf(num1, num2, num3)
print(result)
print("Greatest number of boxes:", result)
print("English in each boxes:", num1 // result)
print("Science in each boxes:", num2 // result)
print("Mathematics in each boxes:", num3 // result)
0/p:
35
Greatest number of boxes: 35
English in each boxes: 5
Science in each boxes: 7
Mathematics in each boxes: 11
3)Two numbers are said to be amicable numbers if the sum of the factors of one number (except the number itself) gives the other number.
The numbers 220 and 284 are amicable, since the sum of the factors of 220 (except 220) i.e., 1+2+4+5+10+11+20+22+44+55+110 = 284 and the sum of the factors of 284 (except 284) i.e., 1+2+ 4+71+142 = 220. Check whether 1184 and 1210 are amicable numbers.
def find_factors(no):
div = 1
total = 0
while div < no:
if no % div == 0:
# print(f'{div} is a factors of {no}')
total += div
div +=1
return total
# result = find_factors(1184)
# print( result)
num1 = 1184
num2 = 1210
sum1 = find_factors(num1)
sum2 = find_factors(num2)
#print(sum1)
#print(sum2)
print("num1:1184 =",sum1)
print("num2:1210 =",sum2)
o/p:
num1:1184 = 1210
num2:1210 = 1184
Top comments (0)