-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path12.cpp
More file actions
46 lines (35 loc) · 694 Bytes
/
Copy path12.cpp
File metadata and controls
46 lines (35 loc) · 694 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
37
38
39
40
41
42
43
44
45
46
#include <iostream>
using namespace std;
void isPrime(int hcf)
{
for(int i = 2; i <= hcf; i++)
{
if(hcf % i == 0)
{
cout<<hcf<<"is NOT prime number";
}
else
cout<<"not prime";
}
}
int main()
{
int i, num1, num2, min, hcf=1;
cout << "Enter two numbers : ";
cin >> num1 >> num2;
min = num1;
if(num2 < num1)
{
min = num2;
}
for(i = 1; i <= min; i++)
{
if((num1 % i) == 0 && (num2 % i) == 0)
{
hcf = i;
}
}
cout << "Highest Common Factor is: "<< hcf;
isPrime(hcf);
return 0;
}