WAP to find HCF

WAP to find HCF

Hi,

can any one please share teh code to find the HCF of 2 or 3 numbers??

View Answers

August 30, 2012 at 12:54 PM

Here is a java code that finds the hcf of three numbers. You can also find the hcf of two numbers with this code.

import java.util.*;

public class HCFOFNumbers {
        public static int hcf(int a, int b) {
                if (b == 0)
                        return a;
                else
                        return hcf(b, a % b);
        }

        public static int hcf(int a, int b, int c) {

                return hcf(hcf(a, b), c);

        }

        public static void main(String[] args) {
                Scanner input = new Scanner(System.in);
                System.out.print("Enter Number 1: ");
                int num1 = input.nextInt();
                System.out.print("Enter Number 2: ");
                int num2 = input.nextInt();
                System.out.print("Enter Number 3: ");
                int num3 = input.nextInt();
                int hcfOfNumbers = HCFOFNumbers.hcf(num1, num2, num3);
                System.out.println("HCF of three numbers " + num1 + "," + num2
                                + " and " + num3 + " is: " + hcfOfNumbers);
        }
}









Related Tutorials/Questions & Answers:
WAP to find HCF
WAP to find HCF  Hi, can any one please share teh code to find the HCF of 2 or 3 numbers
Find HCF of three numbers in Java Program
Find HCF of three numbers in Java Program In this java tutorial section, you will learn how to determine the HCF (Highest Common Factor) or GCD (Greatest Common Divisor) of three numbers. As you already know that HCF or GCD 
Advertisements
wap
wap  wap to count the number of object created for class using static member method   Hi Friend, Try the following code:ADS_TO_REPLACE_1 class CountObject{ static int ob = 0; public CountObject() { ob = ob + 1
What is WAP?
What is WAP?  What is WAP?   Hi, Check the tutorial: What is WAP? Thanks
ModuleNotFoundError: No module named 'scrapy-hcf'
ModuleNotFoundError: No module named 'scrapy-hcf'  Hi, My Python... 'scrapy-hcf' How to remove the ModuleNotFoundError: No module named 'scrapy-hcf' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'hcf-backend'
ModuleNotFoundError: No module named 'hcf-backend'  Hi, My Python... 'hcf-backend' How to remove the ModuleNotFoundError: No module named 'hcf-backend' error? Thanks   Hi, In your python environment
string wap
string wap  WAP to convert stack trace in to a String . Write that Stack Trace in Error Log File along with the class name and Method Name that has thrown the error.in java language
wap for multithreading
wap for multithreading  wap for multithreading   Hi Friend, Try the following code:ADS_TO_REPLACE_1 class Multithreading { int val; boolean value = false; synchronized int get() { if(!value) try { wait(); } catch
Wap Application - MobileApplications
Wap Application  Hi, i need Wap application using Asp.net with c#. were user can download themes, games,wallpapers,songs etc from our application. Almost i create application but i dont know which dll i have to Use to sending
wap site - Development process
wap site  Please tell how to code to identify the mobile modal and manufacturer when any one hit my WAP site. I am using jsp + ejb. Please tell me which technology should i use to do this code. I have a java platform of web j2ee
Version of myfaces>myfaces-wap dependency
List of Version of myfaces>myfaces-wap dependency
What is WAP? Detailed discussion of WAP API with examples.
WAP Tutorial Learn WAP quickly. Learn WAP in 60 minutes Wireless Application Protocol or WAP for short, allows
WAP in java to print the series 1*2*3
WAP in java to print the series 1*2*3  WAP in java to print the series 123
What is WAP? Wireless Application Protocol
; What is WAP?Wireless Application Protocol or WAP for short is simply a protocol... wireless networks. Thus WAP links Wireless Network
WAP Toolkits Motorola - Mobile ADK 1.1 Nokia - WAP Toolkit
; WAP ToolkitsTo develop any WAP...;    List of WAP Toolkits and WAP Gateways 3G
Maven Dependency myfaces-wap >> 1.0.9rc3
You should include the dependency code given in this page to add Maven Dependency of myfaces >> myfaces-wap version1.0.9rc3 in your project
Maven Dependency myfaces-wap >> 1.0.9
You should include the dependency code given in this page to add Maven Dependency of myfaces >> myfaces-wap version1.0.9 in your project
Maven Repository/Dependency: myfaces | myfaces-wap
Maven Repository/Dependency of Group ID myfaces and Artifact ID myfaces-wap. Latest version of myfaces:myfaces-wap dependencies. # Version Release Date You can read more at: Maven
wap showing three threads working simulteniously upon single object.
wap showing three threads working simulteniously upon single object.  wap showing three threads working simulteniously upon single object
find the factorial
find the factorial  how to find the factorial through the while loop?   class FindFactorial { public static void main(String[] args) { int value = 5, factorial = 1, temp = value; while
find and substring
find and substring   **import java.io.BufferedReader; import... BufferedReader(new InputStreamReader(System.in)); System.out.println("Enter find...){ } } public void findreplace(String find, String replace
WAP to calculate addition of two distances in feets and inches using objects as functions arguments in java
WAP to calculate addition of two distances in feets and inches using objects as functions arguments in java  WAP to calculate addition of two distances in feets and inches using objects as functions arguments in java   
Q, 12 WAP to calculate addition of two distances in feets and inches using objects as functions arguments in java
Q, 12 WAP to calculate addition of two distances in feets and inches using objects as functions arguments in java  Q, 12 WAP to calculate addition of two distances in feets and inches using objects as functions arguments in java
WAP to calculate addition of two distances in feets and inches using objects as functions arguments in java
WAP to calculate addition of two distances in feets and inches using objects as functions arguments in java  WAP to calculate addition of two distances in feets and inches using objects as functions arguments in java   
WAP to calculate addition of two distances in feets and inches using objects as functions arguments in java
WAP to calculate addition of two distances in feets and inches using objects as functions arguments in java  WAP to calculate addition of two distances in feets and inches using objects as functions arguments in java   
Writing your First WAP Application.
; As mentioned earlier WAP applications...) for WML is provided by WAP Forum and is available
PHP find online users
PHP find online users  How to find the online users in PHP
find and replace in java
find and replace in java  Need 'find and replace' function in Java to find special keyword in XMl such as @,#,!,%..and replace with their corresponding entities
ModuleNotFoundError: No module named 'find'
ModuleNotFoundError: No module named 'find'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'find' How to remove the ModuleNotFoundError: No module named 'find' error
ModuleNotFoundError: No module named 'find'
ModuleNotFoundError: No module named 'find'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'find' How to remove the ModuleNotFoundError: No module named 'find' error
MySql find and replace string
MySql find and replace string  How to find and replace string or special characters in MySql & PHP?   Find and Replace String PHP $result = preg_replace('/\band\b/i', 'foo', $subject
janusgraph find edge with label
janusgraph find edge with label  Hi, I am working on JanusGraph graph server. I want to find all the edges with a particular label. How to find... for find edge with label: g.V().hasLabel('MyLevel') Thanks
idea for find the worm - Security
idea for find the worm  HI Guys, Please give any advise or code for find the worm and prevent the worm.I am doing the project as a distributed antiworm systems.Please help me
Find city latitude and longitude
Find city latitude and longitude  Hi, I have to find find city latitude and longitude for one of map based application. My application is based on Google map and I am adding cities using city latitude and longitude. In my
find the first character is vowel or not
find the first character is vowel or not  hi friend, can u plz send me javascript code for find the wether the first character is a vowel or not. 2) check wether the last character is same as the first character or not 3) check
to find simple interst
to find simple interst  create a class of object insert with a constructor. write a program to find out simple interest   import java.util....; this.t=t; } public void find(){ double rate=r/100; double
Sort the element find mean
Sort the element find mean  Hi Friend, I want to find meaning of some real numbers like, if we have numbers- 52.15, 89.0, 314.48, 845.75, 309.11, 575.36, 398.98, 318.64, 2485.12, 377.44 Then I want to find
find data science jobs
find data science jobs  Hi, I am beginner in Data Science and machine learning field. I am searching for the tutorials to learn: find data... the topic "find data science jobs". Also tell me which is the good
Find the Running time in sql***
Find the Running time in sql***  I have 10 backend jobs in sql which runs at different time intervals. Sample data is shown below Table name:- Job...:00ADS_TO_REPLACE_1 I want to find the running time of both the jobs. (i.e when i run
java find the error1
java find the error1  package com.test.dao; import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; public class DBConnections { public static String userName=""; public static String
find largest value
find largest value  (Assignment 1 - LargestValue)The process of finding the largest value (i.e., the maximum of a group of values) is used frequently...; Java Find Largest Number import java.util.*; class FindLargest
java find the error2
java find the error2  protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub String temp=request.getRequestURI
java find the error3
java find the error3  public String studentDel(StudentBean studObj) throws ClassNotFoundException, SQLException { Connection conObj=DBConnections.setConnection(); PreparedStatement ps
java find the error4
java find the error4  public String executeStudentInsert(HttpServletRequest request ) throws ClassNotFoundException, SQLException { StudentBean beanObj = new StudentBean(); beanObj.setStudentName(request.getParameter("Name
java find the error7
java find the error7   var name=document.forms["insert"]["in_username"]; var age=document.forms["insert"]["in_userage"]; var address=document.forms["insert"]["in_address"]; var phone=document.forms["insert
find eror inc++
find error inc++   include include int main() { int a[10],b[10],i,j,m,n; cout<<"Enter size of matrix"; cin>>m>>n; for(i=0;i<m;i++)//Initializing matrix a for(j=0;j<n;j
java find the error6
Java find the error 6  <script type="text/javascript"> function validation() { var name=document.forms["insert"]["in_username"]; var age=document.forms["insert"]["in_userage"]; var address=document.forms
java find the error5
java find the error5  <%@page import="java.sql.*"%> <%@page import="java.util.*"%> <%@ page session="true"%> <%@page import="java.io.*"%> <%@page import="java.net.*"%> <%@ page language
C++ code to find Entropy
C++ code to find Entropy   consider a discrete memory less source with source s= { S0,S1,S2,S3} with probabilities P0=1/8 , P1= 1/8, P2=1/2 , P3=1/4 prove that h(s^3)=3h(s) using C++ program ? I try this but not true
Please find me a solution that
Please find me a solution that   Write a java program that calculates the area of rectangular, square, triangular, and circle. Your program must have the following: Two classes named "Area" and "AreaTest". Class "Area

Ads