Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

solution to fizzbuzz c#

// if you don't know what FizzBuzz is than read the next lines

// FizzBuzz is one of the most famous programming 
// problems to solve for exercise.
// the user inputs a number and
// if the number is devided by 3 and has no remainder left print Fizz.
// if the number is devided by 5 and has no remainder left print Buzz.
// if the number is devided by both and has no remainder left print FizzBuzz.
// if it does have a remainder print the number

static string FizzBuzz(int n)
{
	if (n % 3 == 0 && n % 5 == 0)
    {
        return "FizzBuzz";
    }
    else if (n % 5 == 0)
    {
        return "Buzz";
    }
    else if (n % 3 == 0)
    {
        return "Fizz"
    }
    else 
    {
    	return num.ToString();
    }
}

// wait before closing
Console.ReadKey();
Comment

PREVIOUS NEXT
Code Example
Csharp :: unity set text value 
Csharp :: unity put children in list 
Csharp :: how to configure session timeout in asp.net core 
Csharp :: unity get rigidbody 
Csharp :: C# check if is first run 
Csharp :: coroutine not eaffected by time.timescale unity 
Csharp :: unity object to mouse 
Csharp :: how refresh just one table in laravel by terminal 
Csharp :: how to delay between lines in unity 
Csharp :: how to check if string can be converted to int c# 
Csharp :: unity animate post processing values 
Csharp :: includes method C# 
Csharp :: c# throw exception 
Csharp :: west of loathing 
Csharp :: unity round to x decimals 
Csharp :: wpf scrollviewer mouse wheel 
Csharp :: c# round number 
Csharp :: perlin noise unity 
Csharp :: c# how do you check if a string contains only digits 
Csharp :: select a object from list based on a value csharp 
Csharp :: SAVE FLOAT UNITY 
Csharp :: c# LCP 
Csharp :: c# compile just one exe 
Csharp :: print array in c# 
Csharp :: random in unity 
Csharp :: c# get month number 
Csharp :: unity c# 
Csharp :: mvc 5 dropdownlist 
Csharp :: c# check if string is all numbers 
Csharp :: unity vscode no autocomplete 
ADD CONTENT
Topic
Content
Source link
Name
3+7 =