Advertisement
kallyy7

Untitled

Mar 3rd, 2018
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.78 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 aaa
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int N1 = int.Parse(Console.ReadLine());
  14.             int N2 = int.Parse(Console.ReadLine());
  15.             if (N1 == N2)
  16.             {
  17.                 Console.WriteLine(N2);
  18.                 Environment.Exit(0);
  19.             }
  20.             for (int i = N2; i >= 0; )
  21.             {
  22.                 N2 = i;
  23.                 i = N1 % N2;
  24.                 N1 = N2;
  25.                 if(N1 % i == 0 && N2 % i == 0)
  26.                 {
  27.                     Console.WriteLine(i);
  28.                     break;
  29.                 }
  30.             }        
  31.         }
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement