Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Program
- {
- static void Main(string[] args)
- {
- Console.Write("Enter 'n':");
- int n = int.Parse(Console.ReadLine());
- Console.Write("Enter 'a':");
- int a = int.Parse(Console.ReadLine());
- Console.Write("Enter 'b':");
- int b = int.Parse(Console.ReadLine());
- Console.WriteLine("Number of dividers:{0}",num_div(n, a, b));
- }
- public static int num_div (int n,int a,int b)
- {
- int k = 0;
- if(a==0)
- {
- throw new DivideByZeroException();
- }
- for (int i = a; i <= b; i++)
- {
- if (n % i == 0)
- {
- k++;
- }
- }
- return k;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment