Pagini recente » Cod sursa (job #2825383) | Cod sursa (job #759884) | Cod sursa (job #143922) | Cod sursa (job #1139597) | Cod sursa (job #27365)
Cod sursa(job #27365)
/***************************************************************************
* Copyright (C) 2007 by Nistor Andrei *
* [email protected] *
* *
* 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 2 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, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include <fstream>
#include <iostream>
using namespace std;
long int N, k=0;
void citire(){
fstream in ( "fractii.in", ios::in );
in>>N;
in.close();
}
void tipar(){
fstream out("fractii.out", ios::out);
out<<k;
out.close();
}
int cmmdc(long int a, long int b){
int r;
do{
r=a%b;
a=b;
b=r;
}while(r);
return a==1;
}
int main ( int argc, char *argv[] )
{
citire();
long int i,j;
for (i=1; i<=N; ++i)
for(j=1; j<=N; ++j)
if (cmmdc(i, j))
++k;
tipar();
return 0;
}