Skip to content

Instantly share code, notes, and snippets.

@dytra
Created July 2, 2019 15:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dytra/a01beb8f4a360c9971d4d8805f67ce07 to your computer and use it in GitHub Desktop.
Save dytra/a01beb8f4a360c9971d4d8805f67ce07 to your computer and use it in GitHub Desktop.
JS Bin find the greatest factor // source https://jsbin.com/bikopog
<!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>
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