Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

javascript gcd

const gcd = (a, b) => b === 0 ? a : gcd(b, a % b);

// Example
gcd(10, 15);    // 5
Comment

gcd using js

function gcd(a, b) {
    if (a == 0)
        return b;
    return gcd(b % a, a);
}

console.log(gcd(24, 30)) // 6
console.log(24 / 6, 30 / 6) // 4 5
//////////////////
//				//
//  4 * 6 = 24  //
//  5 * 6 = 30  //
//              //
//////////////////
Comment

PREVIOUS NEXT
Code Example
Javascript :: jquery run after page load 
Javascript :: return json with jango 
Javascript :: 1line uuid 
Javascript :: node log without newline 
Javascript :: click to copy react 
Javascript :: reduce decimals to 4 digits javascript 
Javascript :: format money javascript commas 
Javascript :: how to convert string to int js 
Javascript :: prettier ignore line 
Javascript :: remove and add active class with jquery 
Javascript :: javascript get number of elements in object 
Javascript :: javascript current date add 30 days 
Javascript :: allow cross origin node 
Javascript :: angular 11 on hover 
Javascript :: moment format sql date 
Javascript :: @ui-kitten/eva-icons npm ERR! code ERESOLVE npm 
Javascript :: js scroll to bottom 
Javascript :: async iife 
Javascript :: how show piece of long text in javascript 
Javascript :: sleep in react 
Javascript :: z index style javascript 
Javascript :: javascript check format uuid 
Javascript :: js alert and redirect 
Javascript :: find a number that is closest to a specific number in javascript 
Javascript :: remove all html tags from string javascript 
Javascript :: react bootstrap colors not working 
Javascript :: jquery show for 5 seconds 
Javascript :: js get time in am 
Javascript :: Javascript how to run hello world 
Javascript :: play background music in html jasvascript 
ADD CONTENT
Topic
Content
Source link
Name
9+7 =