-
Notifications
You must be signed in to change notification settings - Fork 1
/
functions.cpp
70 lines (44 loc) · 848 Bytes
/
functions.cpp
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#include<iostream>
using namespace std;
// int sum(int a,int b){ // function call
// int ans=a+b; // fuction define
// return ans;
// }
// void mul(int x,int y ){
// int ans=x*y;
// cout<<ans<<endl;
// }
bool isPrime(int n){
if(n<2)
return 0;
for(int i=2;i<=7;i=i+1){
if(n%i==0)
return 0;
}
return 1;
}
int fact(int n){
int ans=1;
for(int i=1;i<=n;i=i+1){
ans=ans*i;
}
return ans;
}
int main(){
// int m,n,p,q;
// cout<<"enter the number "<<endl;
// cin>>m>>n;
// cout<<"enter the second numbers"<<endl;
// cin>>p>>q;
// cout<<sum(m,n)<<endl; // function call;
// mul(p,q); // function call;
int a,b;
cout<<"enter the number to check for prime "<<endl;
cin>>a>>b;
cout<<isPrime(a)<<endl;
cout<<isPrime(b)<<endl;
cout<<fact(a)<<endl;
cout<<fact(b)<<endl;
cout<<fact(b-a)<<endl;
return 0;
}