Programming exercises for 小海豹: FizzBuzz

October 13, 2020

Write a program that accepts one command-line argument n (2 >= n <= 100,000) and prints to standard output all natural numbers from 1 to n, but for numbers that are multiplies of 3, it should print “Fizz” instead of the number and for the multiplies of 5 it should print “Buzz” instead of the number. For numbers that are multiplies of both 3 and 5 it should print “FizzBuzz” instead of the number.

Example usage:

moroz:~/teaching/fizz_buzz$ ts-node ./fizzBuzz.ts 25
1
2
Fizz
4
Buzz
Fizz
7
8
Fizz
Buzz
11
Fizz
13
14
FizzBuzz
16
17
Fizz
19
Buzz
Fizz
22
23
Fizz
Buzz

Use JavaScript or TypeScript programming language.

<< Back to blog

Comments (0)

Leave a Reply

Your email address will not be published. Required fields are marked with an asterisk (*).