Skip to content

Commit 6bf50d9

Browse files
authored
Merge pull request ephremdeme#39 from rishabh15b/master
Code for isPrime in cpp language.
2 parents a936c38 + 59b8b89 commit 6bf50d9

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

problems/isPrime.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#include <iostream>
2+
using namespace std;
3+
4+
int main()
5+
{
6+
int n;
7+
cin>>n;
8+
int d=2;
9+
bool divided=false;
10+
while(d<n)
11+
{
12+
if(n%d==0)
13+
{
14+
cout<<"False"<<endl;
15+
divided=true;
16+
}
17+
d++;
18+
}
19+
if(!divided)
20+
{
21+
cout<<"True"<<endl;
22+
}
23+
}

0 commit comments

Comments
 (0)