Saturday, July 30, 2022

Using JS to describe a magic with calculator

And is 134134 divided by some numbers you gonna find = 134, and this way if you do for other number like 234234; 

And first, get the calculator and divide a number like this 732732/732 = 1001, is a big number!!!

we have to discover the numbers that divide that number and leave no rest.

I do that!!!

So let's use code to make that work, here the code:

    <script>

        function find(num){
            let i = num;
            let divid=[];
            while (i>=1){
                num/i;
                if(num%i ===0){
                    divid.push(num/i)
                }
                i--;
            } return divid;
        }
        document.write(find(1001));
    </script>

And the result will be:

1,7,11,13,77,91,143,1001.

Now this is all the numbers that could divide that number but the 91 to 1001 isn't necessary for the magic because they are multiples of the others so if you pick 134134 and in the calculator divide by 7, and after by11 and after by 13 you gonna have 134, or of another way:

If you got 231 and multiply for 7 and multiply for 11 and after for 13 you gonna have 231231. Rute Bezerra de Menezes Gondim

Ps.: A more shit program you can ask after to get the array and make the program discard the result that isn't odd number, so you gonna got each number and divide by the original array and store only the result that isn't divided for none other of the array for that you gonna run a 'for' inside other 'for' and have two variables to count once for the number that will be tested and the other to count every number of the array that will divide.







No comments:

Post a Comment