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