+ 1

Write solution in Python or js

given a positive integer N prints numbers from 1to N...but if a No. is divisible by 3,5,7 its replaced by fizz, buzz, woof respectively. If a No is divisible by more than one of the numbers it should be replaced by a concatenation of the respective words fizz, buzz, woof in this order eg 15 is replaced by fizzbuzz and numbers divisible by 3,5 and 7 should be replaced by fizzbuzzwoof

23rd Mar 2017, 7:41 PM
nyakio
nyakio - avatar
5 ответов
24th Mar 2017, 5:49 AM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 9
There, I made a new one with explanations: https://code.sololearn.com/cnohYAdJ69ik/?ref=app
24th Mar 2017, 7:30 AM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 6
There already is such a code here on SL. Try searching for it.
23rd Mar 2017, 8:22 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 1
I haven't seen it
24th Mar 2017, 3:26 AM
nyakio
nyakio - avatar
+ 1
for i in range (1,200): if i%3==0 and i%5==0 and i%7==0: print 'FizzBuzzWoof' elif i%3==0 and i%5==0 and i%7!=0: print 'FizzBuzz' elif i%3!=0 and i%5==0 and i%7==0: print 'BuzzWoof' elif i%3==0 and i%5!=0 and i%7!=0: print 'Fizz' elif i%3!=0 and i%5==0 and i%7!=0: print 'Buzz' elif i%3!=0 and i%5!=0 and i%7==0: print 'Woof' else: print i #this works as well...but its python 2.7
27th Mar 2017, 7:42 AM
nyakio
nyakio - avatar