Skip to content

Instantly share code, notes, and snippets.

@piratefsh
Last active August 29, 2015 14:20
Show Gist options
  • Save piratefsh/96b23e304f7b267bd082 to your computer and use it in GitHub Desktop.
Save piratefsh/96b23e304f7b267bd082 to your computer and use it in GitHub Desktop.
Crackepop
// 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