Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- If we list all the natural numbers <= 20 that are multiples of 3 xor 5, we get:
- 3, 5, 6, 9, 10, 12, 18, 20
- Note, 15 is not included because multiples of both 3 and 5 are excluded from the above series.
- In a language of your choice, write a program that takes a positive integer 'N' as an argument and prints all multiples of 3 xor 5 up to (and including) N.
- import itertools
- def printmultiple (n):
- if n.isdigit():
- flag_3 = None
- flag_5 = None
- if (n%3 == 0):
- flag_3 = True
- if (n%5 == 0):
- flag_5 = True
- if ( flag_3 == True or flag_5 == True):
- yield n
- newlist = []
- arr = range(0,21)
- for i in arr:
- newlist.append(printmultiple(i))
- print newlist
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement