Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Write a method that prints the numbers from 1 to 100.
- * For multiples of 3 print “Fizz” instead of the number
- * For the multiples of 5 print “Buzz”.
- * For numbers which are multiples of both 3 and 5 print “FizzBuzz”."
- * 1
- * 2
- * Fizz
- * 4
- * Buzz
- * Fizz
- * 7
- * 8
- * Fizz
- * Buzz
- * 11
- * Fizz
- * 13
- * 14
- * FizzBuzz
- */
- /*
- * I have no idea what this candidate was trying to do. Swore division was the right way to go even after
- * we moved the conversation away from code and just made it about math. Left formatting as was given to us.
- */
- for( int i= 1 ; i<= 100; i++)
- {
- Boolean j =( i/3 != 0)
- (Boolean k =( i/5 != 0))
- print (i)
- if ( j == 0)
- { print( "Fizz")
- if (j == 0)
- { print i);)
- if ( k == 0)
- print (" Buzz")
- }
- /*
- * A much better attempt by another candidate. Not a horrible effort. Some syntax issues I'll forgive
- * and a logic issue that may or may not have been found while walking through it: FizzBuzz will never
- * get printed as written.
- */
- for (int i = 1; i <= 100; i ++)
- {
- if i % 3 = 0
- (
- Console.WriteLine("Fizz")
- )
- else i % 5 = 0
- (
- Console.WriteLine("Buzz)
- )
- else (i % 3 = 0 && i % 5 = 0 )
- (
- Console.Write("FizzBuzz")
- )
- elseif
- (
- Console.WriteLine(i)
- )
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement