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