2520是最小的能被1-10中每个数字整除的正整数。
最小的能被1-20中每个数整除的正整数是多少?
2520是最小的能被1-10中每个数字整除的正整数。
最小的能被1-20中每个数整除的正整数是多少?
STDMETHODIMP COuLa::Test5(int number)
{
// TODO: 在此添加实现代码
int iForNumber[MAX_PATH] = {0};
int iForFinalNumber[MAX_PATH] = {0};
for(int i = number; i>0; i--)
{
int c = i;
int j = c;
back_to_add:
for( j = 2;j<=i;j++)
{
if(c%j == 0)
{
c = c/j;
iForNumber[j]++;
goto back_to_add;
}
}
iForNumber[c]++;
for(int y = 0; y<=number; y++)
{
if(iForNumber[y] > iForFinalNumber[y] )
{
iForFinalNumber[y] = iForNumber[y];
}
iForNumber[y] = 0;
}
}
__int64 result = 1;
for(int i = 0; i<=number; i++)
{
while(iForFinalNumber[i]>0)
{
result = result*i;
iForFinalNumber[i]--;
}
}
printf("The Test 5 Number is %d.\n",result);
return S_OK;
}
#define TEST5_NUMBER 20
IOula->Test5(TEST5_NUMBER);
The Test 5 Number is 232792560.