Created
June 16, 2012 05:07
-
-
Save ryuichimatsumoto-single/2940024 to your computer and use it in GitHub Desktop.
how to solve FizzBuzz problem
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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