Skip to content

Commit 795c739

Browse files
authored
Merge pull request #7 from chokri/buzz
Adding Fizz Buzz Algorithm
2 parents bb66060 + e79311f commit 795c739

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

buzz/Makefile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
obj-m += buzz.o
2+
3+
all:
4+
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
5+
clean:
6+
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean

buzz/buzz.c

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/**
2+
* if (theNumber is divisible by 3) then
3+
* print "Fizz"
4+
* else if (theNumber is divisible by 5) then
5+
* print "Buzz"
6+
* else // theNumber is not divisible by 3 or 5
7+
* print theNumber
8+
* end if
9+
*/
10+
11+
#include <linux/kernel.h>
12+
#include <linux/module.h>
13+
14+
int init_module(void){
15+
16+
static int i =0;
17+
for(i=0;i<100;i++){
18+
if( i % 3 )
19+
printk(KERN_INFO "Fizz");
20+
if( i % 5 )
21+
printk(KERN_INFO "Buzz");
22+
else
23+
printk(KERN_INFO "%d", i);
24+
25+
}
26+
27+
return 0;
28+
29+
}
30+
31+
void cleanup_module(void){
32+
printk(KERN_INFO "goodbye world");
33+
}

0 commit comments

Comments
 (0)