Skip to content

Instantly share code, notes, and snippets.

@hillal20
Created September 7, 2018 04:42
Show Gist options
  • Save hillal20/90111e7f635dfbd6a302f39a7d67b537 to your computer and use it in GitHub Desktop.
Save hillal20/90111e7f635dfbd6a302f39a7d67b537 to your computer and use it in GitHub Desktop.
SereneCrimsonVoxel-1 created by hillal20 - https://repl.it/@hillal20/SereneCrimsonVoxel-1
let geant = (a,b)=>{
let big = (x)=>{
let bill = (x)=>{
let fill = []
for ( let i = 0 ; i <= x; i ++){
if ( x % i === 0 ){
fill.push(i)
}
}
return fill;
}
let result = bill(x)
let a = 1
let arr = []
let dill = ( result , x )=>{
if ( a === result.length ){
return arr;
}
if ( x === 1 ){
return arr;
}
if( x % result[a] === 0 ){
arr.push(result[a])
x = x/result[a]
dill(result, x )
}
else{
a++
dill( result , x )
}
}
dill( result, x)
return arr;
}
const A = big(a)
const B = big(b)
const newArr = [];
for( let i = 0 ; i < A.length; i ++){
if( B.includes(A[i]) && !newArr.includes(A[i])){
newArr.push(A[i])
}
}
let total = 1;
for( let i = 0 ; i < newArr.length; i ++){
total *= newArr[i]
}
return total
}
const final = geant(90,30)
console.log(final)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment