myname0

практикум 4. VI.19

Sep 11th, 2015
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.07 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ConsoleApplication1
  8. {
  9.     class Program
  10.     {
  11.         static int TheNumberOfDivisios(int n)
  12.         {
  13.             if (n == 1)
  14.                 return 1;
  15.             else
  16.             {
  17.                 int k = 2;
  18.                 for (int i = 2; i <= n / 2; i++)
  19.                 {
  20.                     if (n % i == 0) k++;
  21.                 }
  22.                 return k;
  23.             }
  24.         }
  25.         static void Main(string[] args)
  26.         {
  27.             Console.WriteLine("Enter a: ");
  28.             int a = int.Parse(Console.ReadLine());
  29.             Console.WriteLine("Enter b: ");          
  30.             int b = int.Parse(Console.ReadLine());
  31.             if(TheNumberOfDivisios(a) > TheNumberOfDivisios(b))
  32.                 Console.WriteLine("The number of divisios more in a ({0}) then b ({1})", TheNumberOfDivisios(a), TheNumberOfDivisios(b));
  33.             else Console.WriteLine("The number of divisios more in b then a");
  34.         }
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment