#include<stdio.h>
int caluculategenerallcm(int arr[],int);
int caluculatelcm(int,int);
int main()
{
int arr[50],n,res,i;
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%d",&arr[i]);
res=caluculategenerallcm(arr,n);
printf("%d",res);
}
int caluculatelcm(int a,int b)
{
int lcm=a;
while(1)
{
if(lcm%b==0&&lcm%a==0)
{
break;
}
lcm++;
}
return lcm;
}
int caluculategenerallcm(int *arr,int len)
{
int i,m;
int l=arr[0];
for(i=1;i<len;i++)
{
m=arr[i];
l=caluculatelcm(l,m);
}
return l;
}
input:
5
10 20 30 40 50
output:
600
int caluculategenerallcm(int arr[],int);
int caluculatelcm(int,int);
int main()
{
int arr[50],n,res,i;
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%d",&arr[i]);
res=caluculategenerallcm(arr,n);
printf("%d",res);
}
int caluculatelcm(int a,int b)
{
int lcm=a;
while(1)
{
if(lcm%b==0&&lcm%a==0)
{
break;
}
lcm++;
}
return lcm;
}
int caluculategenerallcm(int *arr,int len)
{
int i,m;
int l=arr[0];
for(i=1;i<len;i++)
{
m=arr[i];
l=caluculatelcm(l,m);
}
return l;
}
input:
5
10 20 30 40 50
output:
600
No comments:
Post a Comment