Sunday, 20 February 2011

GCD of two numbers in java


Java code to to find GCD or Greatest common divisor of two numbers





import java.io.*;




class Test {

    public static void main(String[] args) throws IOException {

      int n1,n2;

      System.out.println("Enter first number:");

      BufferedReader br1=new BufferedReader(new InputStreamReader (System.in));

      n1=Integer.parseInt(br1.readLine());

      System.out.println("Enter

No comments:

Post a Comment