Guest User

Untitled

a guest
Jul 17th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3.  
  4. using namespace std;
  5.  
  6. int FindPrime(int InputNumber){
  7. for (int Temp = 2; Temp < InputNumber;Temp ++){
  8. if (InputNumber % Temp == 0){
  9. return 0;
  10. }
  11. }
  12. cout << "Found A Prime Number: " << InputNumber << endl;
  13. return 1;
  14. }
  15.  
  16. void NPrime(int HowMany){
  17. int Count=0;
  18. for (int CurrentNum = 2;Count < HowMany; CurrentNum ++){
  19. if (FindPrime(CurrentNum)==1){
  20. Count += 1;
  21. }
  22. }
  23. }
  24.  
  25.  
  26. int main(){
  27. int NumOfPrimes=0;
  28. while (1==1){
  29. cout << "Enter a Prime Number" ;
  30. cin >> NumOfPrimes;
  31. NPrime(NumOfPrimes);
  32. }
  33. }
Add Comment
Please, Sign In to add comment