summaryrefslogtreecommitdiff
path: root/src/user/app/prime/main.c
diff options
context:
space:
mode:
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;
+}