Re:FizzBuzz without multiplication or division
by blahedo on Monday May 02, 2011 @02:21AM
(#2505404)
This is a weakened version of FizzBuzz---I was taught the version that has you buzz on any number that is divisible by five OR which has a five in its base-ten representation. Which would be a lot harder to do without multiplication or division. :)
[ Parent
| on HN ]
It would actually be pretty easy to do without (explicit) multiplication or division: just convert it to a string and check text properties. Whether or not it would be any faster is another question, to which I'm almost certain the answer is no.
istr = string(i)
if '5' in istr or istr[-1] == '0':
print "Buzz",For that to be valid, in my opinion, you first have to write an integer-to-string converter that also doesn't use multiplication or division. From what I've seen (and written) of such code, that's not trivial.