This website works better with JavaScript.
Home
Explore
lain.church
Help
Register
Sign In
lunarised
/
C89
Watch
1
Star
1
Fork
0
Code
Issues
0
Pull Requests
0
Releases
0
Wiki
Activity
Browse Source
Lab1 Complete
master
lunarised
5 years ago
parent
c3b158383c
commit
a604b29e34
1 changed files
with
21 additions
and
0 deletions
Split View
Diff Options
Show Stats
Download Patch File
Download Diff File
+21
-0
RountreeLabs/Lab01/isPrime.c
+ 21
- 0
RountreeLabs/Lab01/isPrime.c
View File
@@ -0,0 +1,21 @@
#include <stdio.h>
#include <stdlib.h>
int is_prime(int n){
int i;
for(i=2;i<n;i++){
if(n%i == 0){
return 0;
}
}
return 1;
}
int main(void){
int n = 2;
for (n = 2; n < 100; n++){
if(is_prime(n)){
printf("%d\n", n);
}
}
return EXIT_SUCCESS;
}
Write
Preview
Loading…
Cancel
Save