Last active
August 29, 2015 14:20
-
-
Save piratefsh/96b23e304f7b267bd082 to your computer and use it in GitHub Desktop.
Crackepop
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Write a program that prints out the numbers 1 to 100 (inclusive). | |
// If the number is divisible by 3, print Crackle instead of the number. | |
// If it's divisible by 5, print Pop. If it's divisible by both 3 and 5, print CracklePop. | |
// Note, process.stdout.write prints without newline | |
for(var i = 1; i <= 100; i++){ | |
if(i % 3 == 0){ | |
process.stdout.write('Crackle'); | |
} | |
if(i % 5 == 0){ | |
process.stdout.write('Pop'); | |
} | |
if(i % 3 != 0 && i % 5 !=0){ | |
process.stdout.write(""+i); | |
} | |
process.stdout.write('\n'); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment