summaryrefslogtreecommitdiff
path: root/src/user/app/prime/main.c
diff options
context:
space:
mode:
authorAlex AUVOLAT <alexis211@gmail.com>2012-11-25 21:06:40 +0100
committerAlex AUVOLAT <alexis211@gmail.com>2012-11-25 21:06:40 +0100
commit0dadfa903b7a780b4f88155a6eae7855890b797e (patch)
tree16ab5632128deaaad8643b7fcca11118fc0498e7 /src/user/app/prime/main.c
parente138ba093d5e1acbad0587aee38f9c09415d24ca (diff)
downloadTCE-0dadfa903b7a780b4f88155a6eae7855890b797e.tar.gz
TCE-0dadfa903b7a780b4f88155a6eae7855890b797e.zip
Return to standard C.
Diffstat (limited to 'src/user/app/prime/main.c')
-rw-r--r--src/user/app/prime/main.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/user/app/prime/main.c b/src/user/app/prime/main.c
new file mode 100644
index 0000000..d3ebb7d
--- /dev/null
+++ b/src/user/app/prime/main.c
@@ -0,0 +1,19 @@
+#include <stdio.h>
+
+int is_prime(int i) {
+ int j;
+ for (j = 2; j*j <= i; j++) {
+ if (i % j == 0) return 0;
+ }
+ return 1;
+}
+
+int main(char **args) {
+ int i;
+ for (i = 2; i < 1000000; i++) {
+ if (is_prime(i)) printf("%d\t", i);
+ }
+ printf("\nThat's all prime numbers for today.\n");
+
+ return 0;
+}