-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathpe005.cpp
58 lines (51 loc) · 1.25 KB
/
pe005.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
//code created by NamanNimmo Gera.
//10:32pm, April 10, 2019.
#include<bits/stdc++.h>
using namespace std;
#define MAX 10000000000
#define LL long long int
int main(){
LL i,j,flag;
for(i=20;i<MAX;i++){
flag=1; //you can also take out the LCM OF THE all the numbers recursively :), will get the same answer
for(j=1;j<=20;j++){ //I will stick with the brute force :P
if(i%j != 0){
flag=0;
break;
}
}
if(flag==1){
printf("%lld\n",i);//this will print 232792560
break;
}
}
return 0;
}
--------------------------------------------------------------------------------------------
//Also, the solution for problem 5 on projectEuler+ section on hackerrank.
#include<stdio.h>
#define MAX 10000000000
#define LL long long int
int main(){
int t;
scanf("%d", &t);
while(t--){
int n;
scanf("%d", &n);
LL i,j,flag;
for(i=n;i<MAX;i++){
flag=1;
for(j=1;j<=n;j++){
if(i%j != 0){
flag=0;
break;
}
}
if(flag==1){
printf("%lld\n",i);
break;
}
}
}
return 0;
}