FAQ Database Discussion Community


Adding elements to new array Ruby

arrays,ruby,fizzbuzz
So initially I'm just playing around with the ole 'FizzBuzz' challenge. For those that may be unaware of what this challenge is, allow me to explain. The idea is to print out numbers 1..100 if the number is divisible by 3, it prints Fizz instead of 3; if the number...

Line 13 in Python fizzbuzz program throwing error [closed]

python,fizzbuzz
just wanting to know why my python Fizz Buzz program does not seem to be working, the problem seems to be line 13. Advice would be appreciated as a beginner, i cant seem to spot the problem. def func(fizzbuzz): value = "" for x in range(0,fizzbuzz+1): if x%15==0: value +=...

FizzBuzz doesn't fizz or buzz using case/when

ruby,switch-statement,fizzbuzz
I'm trying to understand how to use a conditional expression in a Ruby case/when statement. This code seems like it should work, but it only prints 1 through 100 inclusive, and never prints "Fizz", "Buzz" or "FizzBuzz". #!/usr/bin/env ruby (1..100).each do |n| case n when n % 3 == 0...

How to “if not an integer , alert and repeat prompt” ? the same with isNAN

javascript,alert,prompt,fizzbuzz
i m struggling with this. How to "if not an integer , alert and repeat prompt" ? I have the alert working , but i cant make it to prompt again. The same with isNAN which is not working at all! Thank you $(document).ready(function () { var fizzBuzz = function...

Why does it work?

python,string,printing,concatenation,fizzbuzz
So I'm learning Python and working through a list of program ideas. Of course I wrote the obligatory FizzBuzz, which worked, but was basically if elif else blablabla. I googled it to see if there are other ways and found this dank one-liner: for i in range(1,101): print("Fizz" * (i...

How would I write a header and implementation file for FizzBuzz in Objective-C?

objective-c,header-files,main,fizzbuzz
EDIT TO ADD: SOLVED AT BOTTOM, see main.m I wanted to try the FizzBuzz Challenge in Objective-C since I'm teaching myself the language. I easily coded it in main.m, but I wondered if there was a way to code it via a header and implementation file. For my main.m version,...