summaryrefslogtreecommitdiff
path: root/src/user/app/prime/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/user/app/prime/main.cpp')
-rw-r--r--src/user/app/prime/main.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/user/app/prime/main.cpp b/src/user/app/prime/main.cpp
new file mode 100644
index 0000000..b2b08a8
--- /dev/null
+++ b/src/user/app/prime/main.cpp
@@ -0,0 +1,17 @@
+#include <IO/IOStream.h>
+
+bool is_prime(int i) {
+ for (int j = 2; j*j <= i; j++) {
+ if (i % j == 0) return false;
+ }
+ return true;
+}
+
+int Main(char** args) {
+ for (int i = 2; i < 1000000; i++) {
+ if (is_prime(i)) stdio.printf("%d\t", i);
+ }
+ stdio.printf("\nThat's all prime numbers for today.\n");
+
+ return 0;
+}