내가 필요로 함수를 작성하는 인수로 수 n 및 반환(문자열로)가장 낮은 가능한 번호를 나눌 수 있습니다으로 모든 숫자 1n. 예를 들어 당 n=4 그런 다음 기능을 반환 12 로 12/4 12/3 12/2 12/1 은 전체의 숫자입니다.
내가 기록하는 기능이는 작동 할 때 번호는 보다 적은 19..위 19 컴퓨터 시간은 점점 더 이상. 할 수 있는 누군가가 나에게 힌트를 줄을 더 나은 방법에 대한 메커니즘이 할 수있는 기능이 더 빠르
public static string Smallest(int n)
{
int good = 0;//will hold number of times we got divide with no remianders
int num = n;//smallest possible number is n
while (true)
{
good = 0;
for (int i=n; i>=1; i--)
{
if (num % i ==0) good++;//meaning we got zero remainder for the divide
if (good == n) return num.ToString();//num of times we got zero remainders == n.
}
num++;
}
}