diff options
author | Alex AUVOLAT <alexis211@gmail.com> | 2012-05-19 11:45:49 +0200 |
---|---|---|
committer | Alex AUVOLAT <alexis211@gmail.com> | 2012-05-19 11:45:49 +0200 |
commit | 499ca6c243b05da176a2d4bd9a2317f0b28afc7f (patch) | |
tree | f55ff788632b017ab8de83b71ad02b0998e1dda5 /src/user/app/prime | |
parent | 7b466345af0d3a7dc5622617ce443a90c64e34a4 (diff) | |
download | TCE-499ca6c243b05da176a2d4bd9a2317f0b28afc7f.tar.gz TCE-499ca6c243b05da176a2d4bd9a2317f0b28afc7f.zip |
Introducing FWIK, the userland C++ framework. Far from complete.
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; +} |