#include <iostream> using namespace std; int main() { int n1, n2; cout << "Enter two numbers: "; cin >> n1 >> n2; while(n1 != n2) { if(n1 > n2) n1 -= n2; else n2 -= n1; } cout << "HCF = " << n1; return 0; } Run Code ...
Display Powers of 2 Using Anonymous Function Find Numbers Divisible by Another Number Convert Decimal to Binary, Octal and Hexadecimal Find ASCII Value of Character Find HCF or GCD Find LCM Find the Factors of a Number Make a Simple Calculator Python Tutorials Python map() Function ...
// C program to find the HCF of// given numbers using recursion#include <stdio.h>intcalculateHCF(intnum1,intnum2) {while(num1!=num2) {if(num1>num2)returncalculateHCF(num1-num2, num2);elsereturncalculateHCF(num1, num2-num1); }returnnum1; }intmain() {intnum1=0;int...
Now that you have seen different methods of writing code for deriving the GCD of two numbers in Python, finally, we introduce you to the simplest Math function that can calculate the GCD in a single line of code. But for this, you have to import the Math package in order to be able ...
Python Program to Find HCF or GCD Python Program to Find LCM Python Program to Check Leap Year Python Program to Find Sum of Natural Numbers Using Recursion Python Program to Find Numbers Divisible by Another Number Python Program To Display Powers of 2 Using Anonymous Function Python Program to...
pythonusingpyenv jupyterlabusingbrew You can find the instructions here:How to install Jupyter Notebook on Mac using Homebrew PS: I didn't want to install another package/version manager (such asconda) in addition tohomebrew. Sorry, something went wrong. ...
Find out the GCD of two numbers using while loop in C language Program to compute gcd of two numbers recursively in Python Program to find GCD or HCF of two numbers using Middle School Procedure in C++ Java Program for GCD of more than two (or array) numbersKickstart Your Career Get cer...
Learn, how to find area of rectangle using C program? Problem statement Given length and breadth of a rectangle, write a C program to calculate area of the rectangle. Calculating area of rectangle To calculate the area of a rectangle, use the simple mathematical formula of rectangle area (len...
In the following tutorial, we will learn how to find Least Common Multiple (LCM) using thePython programming language. But before we get started, let us briefly discuss about LCM. LCM: Least Common Multiple/ Lowest Common Multiple LCM stands for Least Common Multiple. It is a concept of ari...
// JavaScript program to find the LCM of two integers var hcf; const num1 = prompt('Enter a first integer: '); const num2 = prompt('Enter a second integer: '); while(num1 != num2){ if(num1 > num2) num1 -= num2; else num2 -= num1; } hcf = num1; // find LCM let...