Advertisement
Masovski

[C# Basics][Loops-HW] 17.* Calculate GCD

Mar 29th, 2014
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.36 KB | None | 0 0
  1. using System;
  2.  
  3. class CalculateGCD
  4. {
  5.     static void Main()
  6.     {
  7.         int a = int.Parse(Console.ReadLine());
  8.         int b = int.Parse(Console.ReadLine());
  9.        
  10.         while (b != 0)
  11.         {
  12.             int temp;
  13.             temp = b;
  14.             b = a % b;
  15.             a = temp;
  16.         }
  17.         Console.WriteLine("GDC: {0}", a);
  18.     }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement