java basic

java basic

java program for finding LCM and HCF

View Answers

January 20, 2011 at 4:02 PM

Hello, Code is below:

public class MathsDemo {

public static void main(String[] args) {

    MathsDemo demo = new MathsDemo();
    System.out.println("H.C.F./G.C.D.: " + demo.gcd(12, 16));
    System.out.println("L.C.M.: " + demo.lcm(12, 16));

}

int lcm(int a, int b) {
    return (a * b / gcd(a, b));
}

int gcd(int a, int b) {

    if (b > a) {
    a = a + b;
    b = a - b;
    a = a - b;
    }
    if (a != 0 && b != 0)
    return gcd(b, a % b);
    return a;

}

}

I think so this code might help you. :-) Anuj Kumar (Knapster)

Ads









Related Tutorials/Questions & Answers:
java basic
java basic  Java Basics tutorials
java basic
java basic  java program for finding LCM and HCF
Advertisements
java basic
java basic  write java program to evaluate 1+x^2+x^3+x^4+............+x^n
Java basic
Java basic  How can I Use Eclipse to create a project and write a hello world java application
Basic Java Tutorial
Basic Java Tutorial  Hi, Where is the url of Basic Java Tutorials on roseindia.net? Thanks   Hi, You can Learn Java in a Day also? Thanks
java and visual basic
java and visual basic  Hello, Please how does java and visual basic interact or talk
basic java - Java Beginners
basic java  oops concept in java ?  Hi Friend, Please visit the following links: http://www.roseindia.net/java/beginners/oop-in-java.shtml http://www.roseindia.net/java/learn-java-in-a-day/oops.shtml Thanks
Java basic question...
Java basic question...   Design a Java Application project...), emp_desig as String (To hold designation of the employee) and basic as Integer (To hold the basic salary of the employee). (iii) Define and declare a method
java core basic problem
java core basic problem  my question is: write a program that illustrates interface inheritance. interface P is extended by P1 and P2. interface... methode. class Q impliments P12 Instantiate Q and invoke each of its methods.Each
java core basic problem
java core basic problem  my question is: write a program that illustrates interface inheritance. interface P is extended by P1 and P2. interface... methode. class Q impliments P12 Instantiate Q and invoke each of its methods.Each
BASIC Java - Java Tutorials
Basic Java Syntax This tutorial guide you about the basic syntax of the java... of the java which is applicable to all java program : Case Sensitive Java Java... letter and lover case. For example, case and Case are different words in java
top 20 basic programm of java
top 20 basic programm of java  what is the top 20 rule to learn the basic of java.   Learn Java through the following links: http://www.roseindia.net/java/ http://www.roseindia.net/java/beginners/index.shtml
Basic problem for Java experts
Basic problem for Java experts  This assignment will test your knowledge of Arrays Array searching Array sorting Array processing Specification An athletics club require a simple statistical analysis program for analysing lap
Is it possible to learn basic Java in a month?
Is it possible to learn basic Java in a month?  Hi, I am big fan... its right time to learn Java, web programming and make career in Software field. Is it possible to learn basic Java in a month? Thanks
Is it possible to learn basic Java in a month?
Is it possible to learn basic Java in a month?  Hi, I am big fan... its right time to learn Java, web programming and make career in Software field. Is it possible to learn basic Java in a month? Thanks
Is it possible to learn basic Java in a month?
Is it possible to learn basic Java in a month?  Hi, I am big fan... its right time to learn Java, web programming and make career in Software field. Is it possible to learn basic Java in a month? Thanks
Is it possible to learn basic Java in a month?
Is it possible to learn basic Java in a month?  Hi, I am big fan... its right time to learn Java, web programming and make career in Software field. Is it possible to learn basic Java in a month? Thanks
Is it possible to learn basic Java in a month?
Is it possible to learn basic Java in a month?  Hi, I am big fan... its right time to learn Java, web programming and make career in Software field. Is it possible to learn basic Java in a month? Thanks
Is it possible to learn basic Java in a month?
Is it possible to learn basic Java in a month?  Hi, I am big fan... its right time to learn Java, web programming and make career in Software field. Is it possible to learn basic Java in a month? Thanks
Core java Basic
Core java Basic  How to compile a program using the package statement at the first line.Do I have to create a a Seperate Folder with the name of the package in my directory.Please tell me the steps
What are Basic Java Language Elements?
What are Basic Java Language Elements?  Hello, I have learned to setup Java and create first program. I want to know the Basic Java Language Elements. What are Basic Java Language Elements? Which is good tutorials of Java
basic
basic  thank you sir for your nice reply . ......sir my next que, if java program is modified,if the program is compiled & executed without saving it again,its previous execution takes place,why
Java Basic Tutorial for Beginners
Java Basic Tutorial for Beginners - Learn how to setup-development environment and write Java programs This tutorial will get you started with the Java... in Java who wants to get started with Java. After completing these tutorial you
Basic Java programming for Beginners
Basic Java programming for Beginners helps them to learn the fundamentals... programming. Basic Java tutorials of Roseindia help all those by giving them... the lectures and it will step-by-step take you from basic to advance level of Java
basic html
basic html  what is the difference between html4 and html5
code for a simple java program which performs basic arithmetic operation addition,subtraction,multiplication,division........
code for a simple java program which performs basic arithmetic operation addition,subtraction,multiplication,division........  code for a simple java program which performs basic arithmetic operation addition,subtraction
Maven dependency for net.mingsoft - ms-basic version 1.0.36 is released. Learn to use ms-basic version 1.0.36 in Maven based Java projects
( net.mingsoft - ms-basic version 1.0.36 ) in their Java project... in project? Steps to use  net.mingsoft - ms-basic version 1.0.36 in Java...-basic version 1.0.36 java library in your project. Now you can save the file
Maven dependency for net.mingsoft - ms-basic version 1.0.37 is released. Learn to use ms-basic version 1.0.37 in Maven based Java projects
( net.mingsoft - ms-basic version 1.0.37 ) in their Java project... in project? Steps to use  net.mingsoft - ms-basic version 1.0.37 in Java...-basic version 1.0.37 java library in your project. Now you can save the file
Maven dependency for net.mingsoft - ms-basic version 2.1.0 is released. Learn to use ms-basic version 2.1.0 in Maven based Java projects
( net.mingsoft - ms-basic version 2.1.0 ) in their Java project if it is based... in project? Steps to use  net.mingsoft - ms-basic version 2.1.0 in Java...Maven dependency for  net.mingsoft  - Version 2.1.0 of ms-basic
Maven dependency for net.mingsoft - ms-basic version 2.1.1 is released. Learn to use ms-basic version 2.1.1 in Maven based Java projects
( net.mingsoft - ms-basic version 2.1.1 ) in their Java project if it is based... in project? Steps to use  net.mingsoft - ms-basic version 2.1.1 in Java...Maven dependency for  net.mingsoft  - Version 2.1.1 of ms-basic
Maven dependency for net.mingsoft - ms-basic version 2.1.3 is released. Learn to use ms-basic version 2.1.3 in Maven based Java projects
( net.mingsoft - ms-basic version 2.1.3 ) in their Java project if it is based... in project? Steps to use  net.mingsoft - ms-basic version 2.1.3 in Java...Maven dependency for  net.mingsoft  - Version 2.1.3 of ms-basic
Maven dependency for net.mingsoft - ms-basic version 2.1.4 is released. Learn to use ms-basic version 2.1.4 in Maven based Java projects
( net.mingsoft - ms-basic version 2.1.4 ) in their Java project if it is based... in project? Steps to use  net.mingsoft - ms-basic version 2.1.4 in Java...Maven dependency for  net.mingsoft  - Version 2.1.4 of ms-basic
Maven dependency for net.mingsoft - ms-basic version 2.1.6 is released. Learn to use ms-basic version 2.1.6 in Maven based Java projects
( net.mingsoft - ms-basic version 2.1.6 ) in their Java project if it is based... in project? Steps to use  net.mingsoft - ms-basic version 2.1.6 in Java...Maven dependency for  net.mingsoft  - Version 2.1.6 of ms-basic
Maven dependency for net.mingsoft - ms-basic version 2.1.7 is released. Learn to use ms-basic version 2.1.7 in Maven based Java projects
( net.mingsoft - ms-basic version 2.1.7 ) in their Java project if it is based... in project? Steps to use  net.mingsoft - ms-basic version 2.1.7 in Java...Maven dependency for  net.mingsoft  - Version 2.1.7 of ms-basic
Maven dependency for net.mingsoft - ms-basic version 1.0.25 is released. Learn to use ms-basic version 1.0.25 in Maven based Java projects
( net.mingsoft - ms-basic version 1.0.25 ) in their Java project... in project? Steps to use  net.mingsoft - ms-basic version 1.0.25 in Java...-basic version 1.0.25 java library in your project. Now you can save the file
Maven dependency for net.mingsoft - ms-basic version 2.1.11 is released. Learn to use ms-basic version 2.1.11 in Maven based Java projects
( net.mingsoft - ms-basic version 2.1.11 ) in their Java project... in project? Steps to use  net.mingsoft - ms-basic version 2.1.11 in Java...-basic version 2.1.11 java library in your project. Now you can save the file
Maven dependency for net.mingsoft - ms-basic version 2.1.12 is released. Learn to use ms-basic version 2.1.12 in Maven based Java projects
( net.mingsoft - ms-basic version 2.1.12 ) in their Java project... in project? Steps to use  net.mingsoft - ms-basic version 2.1.12 in Java...-basic version 2.1.12 java library in your project. Now you can save the file
Maven dependency for net.mingsoft - ms-basic version 1.0.38 is released. Learn to use ms-basic version 1.0.38 in Maven based Java projects
( net.mingsoft - ms-basic version 1.0.38 ) in their Java project... in project? Steps to use  net.mingsoft - ms-basic version 1.0.38 in Java...-basic version 1.0.38 java library in your project. Now you can save the file
Maven dependency for net.mingsoft - ms-basic version 2.1.2 is released. Learn to use ms-basic version 2.1.2 in Maven based Java projects
( net.mingsoft - ms-basic version 2.1.2 ) in their Java project if it is based... in project? Steps to use  net.mingsoft - ms-basic version 2.1.2 in Java...Maven dependency for  net.mingsoft  - Version 2.1.2 of ms-basic
Maven dependency for net.mingsoft - ms-basic version 2.1.5 is released. Learn to use ms-basic version 2.1.5 in Maven based Java projects
( net.mingsoft - ms-basic version 2.1.5 ) in their Java project if it is based... in project? Steps to use  net.mingsoft - ms-basic version 2.1.5 in Java...Maven dependency for  net.mingsoft  - Version 2.1.5 of ms-basic
Maven dependency for net.mingsoft - ms-basic version 2.1.8 is released. Learn to use ms-basic version 2.1.8 in Maven based Java projects
( net.mingsoft - ms-basic version 2.1.8 ) in their Java project if it is based... in project? Steps to use  net.mingsoft - ms-basic version 2.1.8 in Java...Maven dependency for  net.mingsoft  - Version 2.1.8 of ms-basic
Maven dependency for net.mingsoft - ms-basic version 2.1.10 is released. Learn to use ms-basic version 2.1.10 in Maven based Java projects
( net.mingsoft - ms-basic version 2.1.10 ) in their Java project... in project? Steps to use  net.mingsoft - ms-basic version 2.1.10 in Java...-basic version 2.1.10 java library in your project. Now you can save the file
basic question
basic question  how we create a new table with the same structure and data of another table
basic program
basic program  hii actully i am goin for technical interview on java as fresher so please tell me what these two basic lines means : public static void main(String arg) and System.out.print(); please give me meaning of each
basic doubts
basic doubts  can i write two beans within a same xml file..? Also can i write two xml files within a same package
Maven dependency for com.17jee - e-basic-data version 3.0.1.3 is released. Learn to use e-basic-data version 3.0.1.3 in Maven based Java projects
this version ( com.17jee - e-basic-data version 3.0.1.3 ) in their Java project...; com.17jee - e-basic-data version 3.0.1.3 java library in your project. Now you can...Maven dependency for  com.17jee  - Version 3.0.1.3 of e-basic-data
Maven dependency for org.odpi.egeria - basic-file-connector version 2.6 is released. Learn to use basic-file-connector version 2.6 in Maven based Java projects
to use  org.odpi.egeria - basic-file-connector version 2.6 in Java... and includes  org.odpi.egeria - basic-file-connector version 2.6 java library...Maven dependency for  org.odpi.egeria  - Version 2.6 of basic-file
Maven dependency for org.odpi.egeria - basic-file-connector version 2.7 is released. Learn to use basic-file-connector version 2.7 in Maven based Java projects
to use  org.odpi.egeria - basic-file-connector version 2.7 in Java... and includes  org.odpi.egeria - basic-file-connector version 2.7 java library...Maven dependency for  org.odpi.egeria  - Version 2.7 of basic-file
Maven dependency for org.odpi.egeria - basic-file-connector version 2.9 is released. Learn to use basic-file-connector version 2.9 in Maven based Java projects
to use  org.odpi.egeria - basic-file-connector version 2.9 in Java... and includes  org.odpi.egeria - basic-file-connector version 2.9 java library...Maven dependency for  org.odpi.egeria  - Version 2.9 of basic-file
Maven dependency for org.odpi.egeria - basic-file-connector version 2.10 is released. Learn to use basic-file-connector version 2.10 in Maven based Java projects
? Steps to use  org.odpi.egeria - basic-file-connector version 2.10 in Java... that downloads and includes  org.odpi.egeria - basic-file-connector version 2.10 java...Maven dependency for  org.odpi.egeria  - Version 2.10 of basic-file

Ads