Advertisement
Bob103

C#_3_(II-11)

Sep 29th, 2016
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.03 KB | None | 0 0
  1. class Program
  2.     {
  3.         static int div()
  4.         {
  5.            
  6.             Console.Write("Введите a=");
  7.             int a = Convert.ToInt32(Console.ReadLine());
  8.             Console.Write("Введите b=");
  9.             int b = Convert.ToInt32(Console.ReadLine());
  10.             double sqr1 = b / 2;
  11.             int sum = 0;
  12.  
  13.             for (int j = a; j <= b; j++)
  14.  
  15.                 if (b > 1 && b % 2 == 0)
  16.                 {
  17.                     sum = Convert.ToInt32(b) + 1;
  18.  
  19.  
  20.                     for (int i = 2; i <= sqr1; ++i)
  21.                     {
  22.                         if (b % i == 0)
  23.                         {
  24.                             sum += i;
  25.  
  26.                         }
  27.                     }
  28.                 }
  29.                 else b--;
  30.  
  31.             return sum ;
  32.         }
  33.  
  34.         static void Main(string[] args)
  35.         {
  36.          
  37.             Console.WriteLine("Из промежутка от a до b,максимальная сумма делителей  {0}",div());
  38.         }
  39.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement