Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <stdio.h>
- #include <stdlib.h>
- using namespace std;
- bool isPrime(int num){
- if(num == 1) return false;
- for(int i = 2; i * i <= num; i++){
- if(num % i == 0) return false;
- }
- return true;
- }
- int main(){
- int s, n;
- int counter = 0;
- while(cin >> s >> n){
- srand(s);
- for(int i = 0; i < n; i++){
- int randNum = rand() % 1000;
- // cout << randNum << endl;
- if(isPrime(randNum)) counter++;
- }
- cout << counter;
- counter = 0;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement