Skip to content

Instantly share code, notes, and snippets.

@ryuichimatsumoto-single
Created June 16, 2012 05:07
Show Gist options
  • Save ryuichimatsumoto-single/2940024 to your computer and use it in GitHub Desktop.
Save ryuichimatsumoto-single/2940024 to your computer and use it in GitHub Desktop.
how to solve FizzBuzz problem
#define MAX_VALUE 100
#include<stdio.h>
int main()
{
/*
* How to solve FizzBuzz problem
* Copiled program:http://ideone.com/clgJw
* FizzBuzz Problem explains:http://code.google.com/p/fizzbuzz/
*
*/
int i;
i=1;
for(i=1;i<MAX_VALUE;i++)
{
if(i%15 == 0)
{
printf("FizzBuzz\n");
}else if(i%3 == 0)
{
printf("Fizz\n");
}else if(i%5 == 0)
{
printf("Buzz\n");
}else
{
printf("%d\n",i);
}
}
return 1;
}
<?php
define("MAX_NUMBER","101");
/*
* How to solve FizzBuzz problem
* Copiled program:http://ideone.com/vnG4c
* FizzBuzz Problem explains:http://code.google.com/p/fizzbuzz/
*
*/
for($i=1;$i<MAX_NUMBER;$i++)
{
if($i%15==0)
{
echo "FizzBuzz";
}else if($i%5==0)
{
echo "Fizz";
}else if($i%3==0)
{
echo "Buzz";
}else{
print $i;
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment