I’m creating this algorithm which is supposed to include numbers 1,2,3,4,5 in an equation which looks like this:
@ + ## + ∗ ∗ ∗ + &&&& + $$$$$
The symbols meaning that it could be any one of the 5 but each symbol specifying a certain one of them. Then it is supposed to compare, whether the result of the equation is dividable by 11 and if it is then end the loop.
It isn’t working, please help.
let cypherNum = [1, 2, 3, 4, 5]
function randomNum(min, max) { // min and max included
return Math.floor(Math.random() * (max - min + 1) + min)
}
for (let n = 0;
(n / 11 >= 0.0) && (Math.floor(n / 11) === n / 11) && n / 11 != Infinity; n++) {
function sequence() {
let selector1 = Math.round(randomNum(1, 5))
let number1 = cypherNum[selector1]
cypherNum -= [selector1]
let selector2 = Math.round(randomNum(1, 4))
let number2 = cypherNum[selector2]
cypherNum -= [selector2]
let selector3 = Math.round(randomNum(1, 3))
let number3 = cypherNum[Math.round(selector3)]
cypherNum -= [selector3]
let selector4 = Math.round(randomNum(1, 2))
let number4 = cypherNum[Math.round(randomNum(1, 2))]
cypherNum -= [selector4]
let number5 = cypherNum[1]
cypherNum -= [1]
let num = (number1) + (number2 * 11) + (number3 * 111) + (number4 * 1111) + (number5 * 11111)
}
console.log(sequence())
}





