Created
July 2, 2019 15:20
-
-
Save dytra/a01beb8f4a360c9971d4d8805f67ce07 to your computer and use it in GitHub Desktop.
JS Bin find the greatest factor // source https://jsbin.com/bikopog
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta name="description" content="find the greatest factor"> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<script id="jsbin-javascript"> | |
const X = 123; | |
// console.log(X); | |
const digit = X.toString().length; | |
// console.log(digit); | |
let temp = 0; | |
for( x = 0 ; x < X ; x++) { | |
for(y=digit; y > 1; y--) { | |
let formula = x*y; | |
if(formula < X && x >= temp) { | |
temp = x; | |
} | |
} | |
} | |
console.log(temp); | |
</script> | |
<script id="jsbin-source-javascript" type="text/javascript">const X = 123; | |
// console.log(X); | |
const digit = X.toString().length; | |
// console.log(digit); | |
let temp = 0; | |
for( x = 0 ; x < X ; x++) { | |
for(y=digit; y > 1; y--) { | |
let formula = x*y; | |
if(formula < X && x >= temp) { | |
temp = x; | |
} | |
} | |
} | |
console.log(temp);</script></body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const X = 123; | |
// console.log(X); | |
const digit = X.toString().length; | |
// console.log(digit); | |
let temp = 0; | |
for( x = 0 ; x < X ; x++) { | |
for(y=digit; y > 1; y--) { | |
let formula = x*y; | |
if(formula < X && x >= temp) { | |
temp = x; | |
} | |
} | |
} | |
console.log(temp); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment