Find GCD Using Java

Here my programme will input two number from user and after that it will find Greatest Common Divisor (GCD) .

* To change this template, choose Tools | Templates
* and open the template in the editor.
package gcd;

import javax.swing.JOptionPane;

* @author hizbul
public class Gcd {

* @param args the command line arguments
public static void main(String[] args) {
// TODO code application logic here
int a,b,t,x,gcd;
a= Integer.parseInt(JOptionPane.showInputDialog("Enter First Number:"));
b= Integer.parseInt(JOptionPane.showInputDialog("Enter Second Number:"));
else if(b==0)gcd=a;
System.out.println("GCD is:"+gcd);

Software Engineer at The Jaxara IT Ltd , Dhaka , Bangladesh

Tagged with: ,
Posted in JAVA

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: