Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- /* run this program using the console pauser or add your own getch, system("pause") or input loop */
- #include <time.h>
- #include <vector>
- #include <cmath>
- using namespace std;
- bool is_prime(long long num)
- {
- for (long long i = 2; i<sqrt(num); i++) {
- if (num % i == 0) {
- // вывести, что n не простое, так как делится на i
- return false;
- }
- }
- return true;
- }
- int main(int argc, char** argv) {
- std::vector<long long> numbers;
- long long start_digit = 979999999797;
- time_t start, end;
- time(&start);
- for(long long i=start_digit;i<start_digit+200;i++){
- if(is_prime(i)){
- numbers.push_back(i);
- }
- }
- time(&end);
- double seconds = difftime(end, start);
- for(long long n : numbers) cout << n << endl;
- printf("The time: %f seconds\n", seconds);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement