- #include <stdio.h>
- #include <stdlib.h>
-
- //La fonction PGDC en récursif
- /*
- long PGCD(long a, long b, long r)
- {
- if (!r) return b;
- PGCD(b,r,b%r);
- }
- */
-
- //La fonction PGDC en itératif
-
- long PGCD(long a, long b)
- {
- long r;
-
- r=a%b;
-
- while(r)
- {
- a=b;
- b=r;
- r=a%b;
- }
- return b;
- }
-
- long PPCM(long a, long b)
- {
- return (a*b)/PGCD(a,b);
- }
-
-
- int main()
- {
- printf("%d\n",PGCD(731371571,775515735)); //,731371571%775515735
- printf("%d\n",PPCM(731371571,775515735));
- system("pause");
- }
#include <stdio.h>
#include <stdlib.h>
//La fonction PGDC en récursif
/*
long PGCD(long a, long b, long r)
{
if (!r) return b;
PGCD(b,r,b%r);
}
*/
//La fonction PGDC en itératif
long PGCD(long a, long b)
{
long r;
r=a%b;
while(r)
{
a=b;
b=r;
r=a%b;
}
return b;
}
long PPCM(long a, long b)
{
return (a*b)/PGCD(a,b);
}
int main()
{
printf("%d\n",PGCD(731371571,775515735)); //,731371571%775515735
printf("%d\n",PPCM(731371571,775515735));
system("pause");
}