generated from OPCODE-Open-Spring-Fest/template
-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #157 from Kaizo8/shreshth
Shreshth
- Loading branch information
Showing
1 changed file
with
55 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,55 @@ | ||
//Write your code here | ||
#include <bits/stdc++.h> | ||
using namespace std; | ||
int main() | ||
{ | ||
long long int t; | ||
cin >> t; | ||
while (t--) | ||
{ | ||
long long int d; | ||
cin >> d; | ||
if (d == 1) | ||
{ | ||
cout << 6 << endl; | ||
continue; | ||
} | ||
|
||
long long int fac1 = 1 + d; | ||
bool p = true; | ||
while (p) | ||
{ | ||
for (int i = 2; i < fac1; i++) | ||
{ | ||
if ((fac1 % i) == 0) | ||
{ | ||
fac1++; | ||
break; | ||
} | ||
if (i == fac1 - 1) | ||
{ | ||
p = false; | ||
} | ||
} | ||
} | ||
bool q = true; | ||
long long int fac2 = fac1 + d; | ||
while (q) | ||
{ | ||
for (int i = 2; i < fac2; i++) | ||
{ | ||
if ((fac2 % i) == 0) | ||
{ | ||
fac2++; | ||
break; | ||
} | ||
if (i == fac2 - 1) | ||
{ | ||
q = false; | ||
} | ||
} | ||
} | ||
|
||
cout << fac1 * fac2 << endl; | ||
} | ||
return 0 ; | ||
} |