Questions tagged [fizzbuzz]

a game, algorithm and a common programming task of replacing any number divisible by three with the word "fizz", and any number divisible by five with the word "buzz"

Fizzbuzz is a game used to teach children division. Implementing an algorithm for that game is sometimes used as an interview task.

https://en.wikipedia.org/wiki/Fizz_buzz

290 questions
1
vote
5 answers

How to prevent surplus comma at the beginning of a concatenated string

I am trying to solve the FizzBuzz question in PHP (in this case using 'ApaBole' instead). Counting from 1 to 100, numbers divisible by 3 should output 'Apa', numbers divisible by 5 should output 'Bole', and numbers divisible by both should output…
1
vote
1 answer

trying to .push from inside of a function to the outside and/or trying to make my function spit out a single line in console.log

I am doing this assignment: Write a function named snapCrackle that takes one parameter: maxValue. This function should loop through 1 up to maxValue (inclusive) and build a string with the following conditions: If a number is odd, concatenate…
brianfuit1
  • 13
  • 4
1
vote
5 answers

What is the star (*) doing in this FizzBuzz solution?

Learning programming in Python and I am doing some challenges. I've run into something I haven't learned yet and was curious what this code is doing. So my challenge is called the "FizzBuzz" challenge. The instructions are simple: Create a…
sdiggles
  • 43
  • 4
1
vote
3 answers

How do I write the fizzbuzz function in Python 3 with an input value?

I am writing a function fizzbuzz and what I want to do is input value and return it as fizz, buzz or fizzbuzz. However, there is a problem with my code. Whenever I run this, I just only get the first condition and it does not continue. Here is the…
Leo Zarni
  • 13
  • 1
  • 3
1
vote
5 answers

JavaScript coding problem called FizzBuzz

I am trying to figure out what I am doing wrong with this problem. I seem to be missing something that is not allowing my code to work. I need to use a function to create an array that takes one number n, and that loops through an array from the…
Tanya
  • 25
  • 3
1
vote
2 answers

JS: Fizz Buzz Sequence Quiz (Display last element in series as Integer in case it equals to Fizz, Buzz or Fizz Buzz)

I'm creating a quiz based on the Fizz Buzz sequence where the user needs to guess the last element in the series. Example: 422, Fizz, 424, Buzz, ? Possible answers should be: Fizz Buzz Fizz Buzz Integer And this is where I'm stuck, in case the…
octavemirbeau
  • 481
  • 6
  • 19
1
vote
2 answers

I get a (T_CONSTANT_ENCAPSED_STRING) parse error when using fizzbuzz.php typed directly from the book I'm using

I'm trying to make the fizzbuzz.php assignment from PHP and MySQL Web Development 5th Edition, page 193. I have typed it exactly as it is in the book, but I get a (T_CONSTANT_ENCAPSED_STRING) parse error (line 9) when I run it. I have tried…
BackupXfer
  • 21
  • 4
1
vote
3 answers

I am trying to better understand recursion by using the FizzBuzz problem in javascript

I don't understand line 18? If the input is 100 how does program print out the number 1 first and end with the number 100 in the array? Any help would be appreciated. function fizzBuzz(n){ //create empty array called results //create base…
Pat8
  • 958
  • 9
  • 19
1
vote
3 answers

FizzBuzz: 15 shows Fizz but no Buzz on newline. Why? Just need clarification

Just trying to understand on why Buzz doesn't appear in the newline after Fizz for 15. Trying to learn JavaScript from Eloquent Javascript and just got into doing the FizzBuzz exercise. Note that I've included a commented out solution where it does…
1
vote
4 answers

Fizz Buzz Solution: Unexpected Token Function?

I'm having some frustration with this code. I may not be seeing it. I keep getting either an "Unexpected Token" or "ILLEGAL" error (the latter which completely preplexed me, considering I've never seen an error like that before in my life. I've…
Adèle B.
  • 19
  • 2
1
vote
2 answers

FizzBuzz giving back random numbers when using getElementById.innerHTML

Hopefully someone can help me out here. I'm very new to coding and learning to write my first fizzbuzz. My code works when I execute it using console.log, but when I try to use getElementById.innerHTML it wants to give back random numbers. Here's…
1
vote
2 answers

'Split' integers in Terminal

In Ruby, I'm trying to solve a quiz as like a FizzBuzz Challenge. My question is "How I can print the integer number |n| adding a comma and space(", ")at the end of they?" To separate the Namaand Team strings I'm using $stdout.print "Team, " &&…
gbs0
  • 13
  • 4
1
vote
1 answer

In a fizzbuzz, why does a program using dicts think 0 is a fizzbuzz?

So I'm quite new to coding and I was experimenting with all the different fizzbuzzs' and I came across one using dicts. When I run it I can easily make any parameters change with 1 keystroke change, which is nice, but I can't figure out why it…
DopaZilla
  • 11
  • 4
1
vote
0 answers

Solving FizzBuzz with Keras

I am trying to solve FizzBuzz using Keras and it works quite well for numbers between 1 and 10.000 (90-100% win rate and close to 0 loss). However, if I try even higher numbers, that is numbers between 1 and 100.000 it doesn't seem to perform well…
LordTribual
  • 4,219
  • 2
  • 28
  • 38
1
vote
7 answers

How to write FizzBuzz in JavaScript without using % operator

I know how to write simple FizzBuzz code in JavaScript: x = 0;while (++x < 1000)console.log((x % 3 ? "" : "Fizz") + (x % 5 ? "" : "Buzz") || x); But how can we get the same result without using the '%' operator?
Dimpu Aravind Buddha
  • 9,505
  • 4
  • 17
  • 23