• Post Reply Bookmark Topic Watch Topic
  • New Topic

Fizz Buzz: did i get something wrong?  RSS feed

 
S. Freeman
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
After reading the Fizz Buzz test, i thought that even i could solve it, but because i was on the bus (without access to a PC until i got home) i started thinking about a solution.
And when i thought of one because i am a beginner i started doubting myself. There must be something that i am did not get right.. Anyway i got home an finally and ran my program..


Write a program that prints out the numbers from 1 through 100, but…

For numbers that are multiples of 3, print “Fizz” instead of the number.
For numbers that are multiples of 5, print “Buzz” instead of the number
For numbers that are multiples of both 3 and 5, print “FizzBuzz” instead of the number.


Outputfor i <= 30, less spam)
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.
26
Fizz.
28
29
FizzBuzz



Dunno if links to other sites are allowed ,http://www.globalnerdy.com/2012/11/15/fizzbuzz-still-works/
(i am not trying to help the dude get more hits).
I am not trying to brag or boost my self confidence, only practice and work will help me with those BUT
I am just genuinely wondering(since the dude made such a big deal of it in his post) if there is something that a beginner can learn from this test? Or is it just a simple problem with a simple solution?
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 37518
554
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your solution is good. The intention isn't for it to be a hard or tricky exercise.

And you'd be amazed at how many people can't do this. Too many "programmers" reply on copy/pasting things together and can't write a simple algorithm.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!