Multiple of 5 :
(1) Input: 6 Output: 1
1 2
2 3
3
5
9
6
(2) Input: 5 Output: 1
1 2
2 3
3 4
4
5
def isMultipleof5(n):
while ( n > 0 ):
n = n - 5
if ( n == 0 ):
return 1
return 0
i = 19
if ( isMultipleof5(i) == 1 ):
print (i, "is multiple of 5")
else:
print (i, "is not a multiple of 5")
Comments
Leave a comment