Javascript - factor 2 numbers -
I have a program on which I am working but need some help. User and maximum number I have a loop that will loop through the numbers of screens and display on the screen. I also need to find factors for each number. I have a loop at the same time for loop, but I'm getting the "allocation size overflow" error
That's what I have yet Done:
function getFactors (lower, high number) {var results = "" low + "+" and "+ high number +" & lt; Br / & gt; & Lt; Br /> (; var x = lowNum; x & lt; = highNum; x ++) {Results + = "& lt; B & gt; "+ X +": & lt; Loop conditions for loop from "; // abortus = 2; while (factor and lieutenant; = lower number) {if (lower minimum frame == 0) {result + = factor +",
In your time-lapse you increase lowNum
instead of factor
, then the loop will run forever to work it in my browser while changing it Just see that users do not have too many numbers and browsers crash / freeze input.
Your argument is also a bit wrong, because you subtract less number of times in your time-loop In your code, you do not basically use X.
This is your time-lapse edited, so it works as intended:
< Pre> while (factor & lt; = x) {if (x% factor == 0) {result + = factor + ", ";} factor ++;}
Comments
Post a Comment