summaryrefslogtreecommitdiff
path: root/src/user/app/prime
diff options
context:
space:
mode:
Diffstat (limited to 'src/user/app/prime')
-rw-r--r--src/user/app/prime/Makefile2
-rw-r--r--src/user/app/prime/main.c19
-rw-r--r--src/user/app/prime/main.cpp18
3 files changed, 20 insertions, 19 deletions
diff --git a/src/user/app/prime/Makefile b/src/user/app/prime/Makefile
index 0e86c31..3a524e9 100644
--- a/src/user/app/prime/Makefile
+++ b/src/user/app/prime/Makefile
@@ -1,6 +1,6 @@
Obj = main.o
Out = prime.elf
-include $(SrcPath)/user/app/fwik.make
+include $(SrcPath)/user/app/common.make
LDFLAGS += -Map prime.map
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;
+}
diff --git a/src/user/app/prime/main.cpp b/src/user/app/prime/main.cpp
deleted file mode 100644
index be8780f..0000000
--- a/src/user/app/prime/main.cpp
+++ /dev/null
@@ -1,18 +0,0 @@
-#include <IO/IOStream.h>
-#include <String.h>
-
-bool is_prime(int i) {
- for (int j = 2; j*j <= i; j++) {
- if (i % j == 0) return false;
- }
- return true;
-}
-
-int Main(String *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;
-}