Cod sursa(job #3309856)
| Utilizator | Data | 9 septembrie 2025 21:48:54 | |
|---|---|---|---|
| Problema | Sum | Scor | 50 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.49 kb |
#include <fstream>
using namespace std;
ifstream fin("sum.in");
ofstream fout("sum.out");
int cmmdc(int a, int b)
{
if(b == 0)
return a;
else
return cmmdc(b, a % b);
}
int main()
{
int n, x;
fin >> n;
for(int i = 1; i <= n; i++)
{
fin >> x;
long long s = 1;
for(long long j = 2; j <= 2 * x; j++)
if(cmmdc(j, x) == 1)
s += j;
fout << s << "\n";
}
return 0;
}
