aboutsummaryrefslogtreecommitdiff
path: root/challenge-146/ulrich-rieke/cpp/ch-1.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'challenge-146/ulrich-rieke/cpp/ch-1.cpp')
-rw-r--r--challenge-146/ulrich-rieke/cpp/ch-1.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/challenge-146/ulrich-rieke/cpp/ch-1.cpp b/challenge-146/ulrich-rieke/cpp/ch-1.cpp
new file mode 100644
index 0000000000..415867763f
--- /dev/null
+++ b/challenge-146/ulrich-rieke/cpp/ch-1.cpp
@@ -0,0 +1,23 @@
+#include <iostream>
+#include <cmath>
+
+bool isPrime( int number ) {
+ int stop = std::sqrt( static_cast<double>( number ) ) ;
+ for ( int i = 2 ; i <= stop ; ++i )
+ if ( number % i == 0 )
+ return false ;
+ return true ;
+}
+
+int main( ) {
+ int current = 1 ;
+ int numberOfPrimes = 0 ;
+ while ( numberOfPrimes != 10001 ) {
+ current++ ;
+ if ( isPrime( current ) ) {
+ numberOfPrimes++ ;
+ }
+ }
+ std::cout << current << std::endl ;
+ return 0 ;
+}