Total members 11893 |It is currently Fri Nov 15, 2024 10:01 am Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





This is the code i made to get greatest comman divisor of two integer numbers :
java code
package javaapplication5;

import java.util.Scanner;

/**
*
* @author sami
*/
public class GCD {

/** Creates a new instance of GCD */
public GCD() {
System.out.println("Greatest Comman Divisor ");
Scanner inscan=new Scanner(System.in);
System.out.println("Please enter the first number ");
a=inscan.nextInt();
System.out.println("Please enter the second number ");
b=inscan.nextInt();
System.out.println("The GCD("+a+","+b+")= "+get_GCD() );
}
public int get_GCD()
{
int remmender;
while(b>0)
{
remmender=a%b;
a=b;
b=remmender;
}
return a;
}

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
new GCD();
// TODO code application logic here
}

private int a;
private int b;

}




_________________
M. S. Rakha, Ph.D.
Queen's University
Canada


Author:
Mastermind
User avatar Posts: 2715
Have thanks: 74 time
Post new topic Reply to topic  [ 1 post ] 

  Related Posts  to : Greatest Comman Divisor using Java
 Greatest common divisor     -  
 greatest common divisor (GCD)     -  
 greatest common divisor-code-c     -  
 2d game in java-Monster-Java 2D Game Graphics and Animation     -  
 Using FTP in java     -  
 what is java     -  
 Java course     -  
 What is Java API?!!!     -  
 java or .net     -  
 need help in java     -  



Topic Tags

Java Algorithms
cron





Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com