Using Python and the command of for loop and range, while loop, if_elif_else ,
1. In this problem you must design an algorithm to identify
whether a number is
multiple of 3, 5 and 7 . That is, the algorithm receives
a number and must tell the user if the number is:
(make a program)
• only multiple of 3
• only multiple of 5
• only multiple of 7
• only multiple of 3 and 5
• only multiple of 3 and 7
• only multiple of 5 and 7
• multiple of 3, 5 and 7
• is not a multiple of 3, 5, or 7
Please include a desktop test with the numbers 48959,48960 y 48961.
/*If you have any query do comment in the comment section else like the solution*/
num = int(input())
if num%3 == 0 and num%5 == 0 and num%7 == 0:
print("{} is divsible by 3, 5 and 7".format(num))
elif num%3 == 0 and num%5 == 0:
print("{} is divsible by 3 and 5".format(num))
elif num%3 == 0 and num%7 == 0:
print("{} is divsible by 3 and 7".format(num))
elif num%7 == 0 and num%5 == 0:
print("{} is divsible by 5 and 7".format(num))
elif num%3 == 0:
print("{} is divsible by 3".format(num))
elif num % 5 == 0:
print("{} is divsible by 5".format(num))
elif num % 7 == 0:
print("{} is divsible by 7".format(num))
else:
print("{} is not divisible by 3, 5, or 7".format(num))
Output:
Get Answers For Free
Most questions answered within 1 hours.