x=32 y=24 GCM=8 |
前田稔(Maeda Minoru)の超初心者のプログラム入門
![]()
![]()
/**********************************************/
/*★ C# GCM Function Program 前田 稔 ★*/
/**********************************************/
using System;
class console
{
public static int Main()
{
int x = 32;
int y = 24;
int vgcm;
gcm(x,y,out vgcm);
Console.WriteLine("x={0} y={1} GCM={2}",x,y,vgcm);
System.Console.ReadLine();
return 0;
}
static void gcm(int n, int m, out int ans)
{
while(n!=m)
{ if (n>m) n-= m;
else m-= n;
}
ans= n;
}
}
|
![]()
![]()