Pagini recente » Cod sursa (job #1102719) | Cod sursa (job #593918) | Cod sursa (job #227619) | Cod sursa (job #1650694) | Cod sursa (job #1324536)
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <iostream>
#include <fstream>
#include <cmath>
using namespace std;
int v[1000005];
ifstream in;
ofstream out;
long long int getAnswer(int);
int main(int argc, char *argv[])
{
in.open("fractii.in");
out.open("fractii.out");
int n;
in >> n;
out << getAnswer(n) << endl;
in.close();
out.close();
return 0;
}
long long int getAnswer(int n)
{
long long int nr = 0;
for (int i = 2; i <= n; i++) {
v[i] = i - 1;
}
for (int i = 2; i <= n; i++) {
for(int j = 2 * i; j <= n; j += i) {
v[j] = v[j] - v[i];
}
}
for(int i = 1; i <= n; i++) {
nr += v[i];
}
nr *= 2;
nr++;
return nr;
}