Module: 서브루틴: 절차 및 기능 - 2


Problem

4/10

숫자의 제수의 수

Problem

자연수의 약수를 반환하는 함수 작성
예.
<몸>
입력 출력
6 4
1
using System;  
2
class Program  
3
{   
4
    static int countDivisors(int x)  
5
    {  
6
7
        for (int i = 1; i <= x; i++)  
8
        {  
9
            if (x % i == 0)  
10
            {  
11
                count += 1;  
12
            }  
13
        }  
14
        // верните нужную переменную  
15
    }  
16
    static void Main()  
17
    {  
18
        int x = Convert.ToInt32(Console.ReadLine());  
19
        Console.WriteLine(countDivisors(x));  
20
    }  
21
}  

     

Program check result

To check the solution of the problem, you need to register or log in!