Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

lcm of two large positive integers java

import java.util.Scanner;
import java.math.BigInteger;
public class LCM2N {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        BigInteger a = sc.nextBigInteger();
        BigInteger b = sc.nextBigInteger();
        System.out.println(a.multiply(b).divide(a.gcd(b)));
     	// lcm(121212121212121212,45678978) = 102534181818181818079284
    }
}
Comment

PREVIOUS NEXT
Code Example
Java :: Java FileOutputStream to write data to a File 
Java :: an internal error occurred during initializing java tooling . java.lang.nullpointerexception 
Java :: array reverse in java 
Java :: quicksort java 
Java :: declaring variables views in java android 
Java :: long to double in java 
Java :: overload and override in java 
Java :: java mostrar resultados ventana grafica 
Java :: no of words in a string in java 
Java :: linked list vs array list vs vector 
Java :: java code for scientific calculator GUI 
Java :: .jar window immediately closes on doubleclick 
Java :: java check if int is null 
Java :: fullscreen libgdx 
Java :: object type in java 
Java :: check if LinkedList is empyth java 
Java :: javac encoding utf-8 
Java :: java session timeout 
Java :: how to recognize a pressed key in java 
Java :: Unable to find bundled Java version mac m1 
Java :: next method jdbc 
Java :: java clear scanner 
Java :: android studio find all views in layout 
Java :: java infinite for loop 
Java :: how to make a rest api in spring 
Java :: 2-dimensional Array java 
Java :: qr code spring boot 
Java :: Java long Keyword 
Java :: java change hashmap value 
Java :: java to c# converter 
ADD CONTENT
Topic
Content
Source link
Name
3+7 =