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
-2
votes
3 answers

Beginner Question: Mod Arithmetic Syntax Error

I’m trying to make a fizzbuzz program: count up to n; for each i up to n, print “fizz” if a multiple of 3, and “buzz” if a multiple of 5 — if a multiple of both, print “fizzbuzz”. I’m using modular arithmetic, but for some reason my syntax is…
Grant
  • 1
-2
votes
2 answers

How do I get rid of these numbers

I need to replace the numbers with the words sample output: 1 2 Fizz 4 Buzz Fizz 7 8 Fizz Buzz 11 Fizz 13 14 FizzBuzz input sample: 15 This is my code below #include int main() { int a; int i = 1; scanf("%d",&a); …
vince
  • 1
  • 1
-2
votes
3 answers

My code is not running. This code is the famous "FizzBuzz" question

I am trying to run this code but it's not working. I don't know how to return the input j as a string. This is the error /tmp/D2FFE31F-B533-48DF-AC15-F1EA8A029FCF.q0h9za/main.swift:15:1: error: missing return in a function expected to return…
Cool coder
  • 13
  • 4
-2
votes
2 answers

return statement not responding what should i do

def fizz_buzz(num): if num % 3 == 0 and num % 5 == 0: return "Fizz Buzz" elif num % 3 == 0: return "Fizz" elif num % 5 == 0: return "Buzz" return num fizz_buzz(15) I don't know why my return statement is…
-2
votes
3 answers

How do I shorten that specific code in C#?

I am a beginner C# learner. I am trying to learn through an app called SoloLearn. In the app, it wants me to replace 3 and its multiples in a series of numbers with "*". For example; the input is n number, let's say 7, the output should go "12 * 45…
oceilot
  • 11
  • 2
-2
votes
1 answer

Issue Making FizzBuzz

Rules of FizzBuzz Players generally sit in a circle. The player designated to go first says the number "1", and each player thenceforth counts one number in turn. However, any number divisible by three is replaced by the word fizz and any…
-2
votes
1 answer

Why is my FizzBuzz code not outputting correctly?

function counter(numOne, numTwo) { for (let i = 0; i <= 100; i++) { if (i % numOne === 0) { console.log("Fizz"); } if (i % numTwo === 0) { console.log("Buzz"); } if (i % numOne === 0 && i % numTwo === 0) { …
Cutecat42
  • 77
  • 8
-2
votes
1 answer

How to write Fizzbuzz Program in Kotlin?

I'm just a begineer in kotlin and I'm am writing the Fizzbuzz program in kotlin but can't. Can anyone help me out?
-2
votes
3 answers

Fizz Buzz question with extra difficulty layer

I am trying to solve the Fizz Buzz question with an extra layer. This is what I have so far. All this works fine but I need one more extra condition. It's JS Unit testing For any other input (valid or otherwise) return a string representation of…
beast3372
  • 13
  • 1
-2
votes
3 answers

FizzBuzz solution in an arraylist

I have been given the classic FizzBuzz test to do. However, the problem has an extra task which is to display the results in an ArrayList. I know that you can't just stick an integer and string values together in a list. Hence, this is causing…
G_Li
  • 1
  • 1
-2
votes
4 answers

C# FizzBuzz Switch Solution

Is it possible to create the FizzBuzz solution in C# with the switch construct. I've found solutions that work for JavaScript and other languages, but these (or the syntax equivalent) don't seem to be working in C#. For reference, I'll write the if…
Macimoar
  • 69
  • 2
  • 8
-2
votes
1 answer

What is this way of resolving the Fizzbuzz challenged called?

I am new to programming, and I am currently doing the FizzBuzz test, it looks simple at first but we got some requirements to perform it: I can use only one if. No multiple branches, ternary operators or else. Unit tests. I made it by using switch…
user5978274
-2
votes
2 answers

I "solved" FizzBuzz, but I don't understand why it's working

I'm completely green. Just started reading Eloquent JavaScript, and Chapter 2 gets into some exercises. Apparently the "FizzBuzz" problem needs no introduction. I spent the better part of an hour giving it an honest go, trying different…
Oiohwah
  • 3
  • 4
-2
votes
1 answer

Why does this C++ prime checker and summer return wrong results?

I don't get why the summation never works properly, yet sums consistently. It dosent throw any errors, but never gets the correct result. According to wolfram|alpha i can be off with as much as 20 000 000 000 for large calculations. I have no idea…
ZxZ
  • 1
  • 2
-2
votes
2 answers

Condition (num % 3 === 0): why does it need to compare to 0?

I have a simple fizzbuzz here: var num = 1; while (num <= 20) { switch(true){ case(num%3 === 0 && num%5 === 0): console.log('fizzbuzz'); break; case(num%3 === 0): console.log('fizz'); …
jdev99
  • 95
  • 1
  • 3
  • 11