Program to find GCD/HCF of two numbers in Kotlinpackage com.includehelp.basic import java.util.* //Main Function entry Point of Program fun main(args: Array<String>) { //Input Stream val scanner = Scanner(System.`in`) //input First integer print("Enter First Number : ") val first: ...
The largest integer which can perfectly divide two integers is known as GCD or HCF of those two numbers.For example, the GCD of 4 and 10 is 2 since it is the largest integer that can divide both 4 and 10.Example: 1. Find HCF/GCD using for loop...
Program to find subtraction of two numbers in C #include<stdio.h>intmain(){inta,b,sub;//Read value of aprintf("Enter the first no.:");scanf("%d",&a);//Read value of bprintf("Enter the second no.:");scanf("%d",&b);//formula of subtractionsub=a-b;printf("subtract is =%d...
For example, the L.C.M. of 12 and 14 is 84. Program to Compute LCM # Python Program to find the L.C.M. of two input number def compute_lcm(x, y): # choose the greater number if x > y: greater = x else: greater = y while(True): if((greater % x == 0) and (greater...
// 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...
// Java program to calculate the // HCF of two numbers import java.util.Scanner; public class Main { static int CalHcf(int num1, int num2) { int temp = 0; if (num1 == 0 || num2 == 0) return 0; while (num2 != 0) { temp = num1 % num2; num1 = num2; num2 = ...
C program to find the remainder of two numbers without using modulus (%) operator/* * Program to get remainder without using % operator. */ #include <stdio.h> int main() { int a,b,rem; printf("Enter first number :"); scanf("%d",&a); printf("Enter second number :"); scanf("...
Here, we imported the fmt package that includes the files of package fmt then we can use a function related to the fmt package.In the main() function, we read two integer numbers and calculated the HCF. After that printed the result on the console screen....
// 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;...
C program to find area and perimeter of circle C program to find area of a rectangle C program to calculate HCF of two numbers C program to multiply two numbers using plus operator C program to demonstrate example of global and local scope ...