Advertisement
jdalbey

Recursive GCD in Java

May 21st, 2014
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.26 KB | None | 0 0
  1. public class GCD{
  2.    
  3.    public static void main(String[] args)
  4.    {
  5.       System.out.println(gcd(30,6));
  6.    }
  7.    public static long gcd ( long a, long b )
  8.    {
  9.       if (b == 0 )
  10.          return a;
  11.       else
  12.          return gcd ( b, a%b );
  13.    }
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement