Ask HN: What counter-offer should I make for the position of CTO at a startup?
1 pointsby Encryptor0 comments
if (not (i mod 3) and not (i mod 5)): print i;
print "\n";
Even though the 3rd condition involves a few extra arithmetic/logical operations, these are way faster than memory operations. The strings 'Fizz', 'Buzz' and "\n" are allocated at the beginning of the program. There is no "result" variable that needs to be allocated/deallocated on every iteration and there is also no need to store the result in an array, because the task is to write a program that "prints" the numbers from 1 to 100. Plus, wouldn't you want to store it in a string, instead of allocating memory for arrays?