[ create a new paste ] login | about

Recent implementations of FizzBuzz, in:
[ C | C++ | Python ]

C:
pasted on Jan 24:
#include<stdio.h>
int main(void)
{
    int i ;
 
    for(i=1;i<101;i++){
        if(i%3==0 && i%5==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 0;
}
view (22 lines, 100 lines of output)
pasted on Dec 8:
#include<stdio.h>
int main(void)
{
    int i ;
 
    for(i=1;i<101;i++){
        if(i%3==0 && i%5==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 0;
}
view (22 lines, 100 lines of output)


C++:
pasted on Feb 2:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include<stdio.h>
int main(void)
{
    int i ;
 
    for(i=1;i<101;i++){
        bool is3 = i%3 == 0;
        bool is5 = i%5 == 0;
        if (is3) 
            printf("Fizz");
        if (is5)
            printf("Buzz");
        if (!is3 && !is5)
            printf("%d", i);
        printf("\n");
    }
     
    return 0;
}
view (19 lines, 100 lines of output)


Python:
pasted on Feb 11:
1
2
3
4
5
6
7
8
9
for i in range(1, 101):
    if i % 3 == 0 and i % 5 == 0:
        print("FizzBuzz")
    elif i % 3 == 0:
        print("Fizz")
    elif i % 5 == 0:
        print("Buzz")
    else:
        print(i)
view (9 lines, 100 lines of output)
pasted on Feb 11:
1
2
3
4
5
6
7
8
9
for i in range(1, 101):
    if i % 3 == 0 and i % 5 == 0:
        print("FizzBuzz")
    elif i % 3 == 0:
        print("Fizz")
    elif i % 5 == 0:
        print("Buzz")
    else:
        print(i)
view (9 lines, 100 lines of output)