Advertisement
Fundamentalen

CalculateGCD

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