forked from TusharKukra/CppPrograms
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPatternPrime
More file actions
36 lines (35 loc) · 653 Bytes
/
Copy pathPatternPrime
File metadata and controls
36 lines (35 loc) · 653 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
28
29
30
31
32
33
34
35
36
#include<iostream>
using namespace std;
int main(){
int isPrime(int counter);
int n;
cout<<"Enter no. of rows";
cin>>n;
for(int i=0;i<n;i++){
int counter=1;
for(int j=0;j<=i;j++){
while(!isPrime(counter)){
counter++;
}
cout<<counter<<" ";
counter++;
}
cout<<endl;
}
return 0;
}
int isPrime(int num){
int result=1;
for(int k=2;k<num;k++){
if(num%k==0){
result=0;
break;
}
}
if(result==1 || num==2 || num==1){
return 1;
}
else{
return 0;
}
}