diff options
Diffstat (limited to 'src/user/app/prime')
-rw-r--r-- | src/user/app/prime/Makefile | 6 | ||||
-rw-r--r-- | src/user/app/prime/main.cpp | 17 |
2 files changed, 23 insertions, 0 deletions
diff --git a/src/user/app/prime/Makefile b/src/user/app/prime/Makefile new file mode 100644 index 0000000..0e86c31 --- /dev/null +++ b/src/user/app/prime/Makefile @@ -0,0 +1,6 @@ +Obj = main.o +Out = prime.elf + +include $(SrcPath)/user/app/fwik.make + +LDFLAGS += -Map prime.map 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; +} |