-
-
Notifications
You must be signed in to change notification settings - Fork 486
Expand file tree
/
Copy pathsol7.dart
More file actions
27 lines (24 loc) · 654 Bytes
/
sol7.dart
File metadata and controls
27 lines (24 loc) · 654 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// Author : Devmaufh
// Email : [email protected]
/**
* [Problem 7](https://projecteuler.net/problem=7) solution
* Problem Statement:
* By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13.
* What is the 10 001st prime number?
*/
void main() {
int numberOfPrimes = 0;
int number = 1;
while (numberOfPrimes < 10001) {
number++;
if (isPrime(number)) {
numberOfPrimes++;
}
}
print(" 10 001st prime number is => $number ");
}
bool isPrime(int number) {
if (number < 2) return false;
for (int i = 2; i < number; i++) if (number % i == 0) return false;
return true;
}