using System; using System.Collections.Generic; using System.Linq; using System.Text;namespace CommonM { class Program { static void Main(string[] args) { int[] Arr = { 4, 2, 45, 76, 78, 3, 9 };//待计算的整数数组 System.Console.WriteLine(f(7, Arr)); System.Console.Read(); } static int f(int n, int[] A) { if (n == 1) return A[0]; else { int k = n; k--; return f1(f(n - 1, A), A[k]); } } static int f1(int a, int b)//求两个整数最小公倍数 { int temp = a * b; while (a != b) { if (a > b) a = a - b; else b = b - a; } return temp / a; } } }
using System.Collections.Generic;
using System.Linq;
using System.Text;namespace CommonM
{
class Program
{
static void Main(string[] args)
{
int[] Arr = { 4, 2, 45, 76, 78, 3, 9 };//待计算的整数数组
System.Console.WriteLine(f(7, Arr));
System.Console.Read(); }
static int f(int n, int[] A)
{
if (n == 1)
return A[0];
else
{
int k = n;
k--;
return f1(f(n - 1, A), A[k]);
}
}
static int f1(int a, int b)//求两个整数最小公倍数
{
int temp = a * b;
while (a != b)
{
if (a > b)
a = a - b;
else
b = b - a;
}
return temp / a;
}
}
}