Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #29258

Memory allocation overflow

Newsgroups comp.lang.javascript
Date 2016-01-16 09:58 -0800
Message-ID <4eb1912d-87cd-4e4b-a4b0-5154de752831@googlegroups.com> (permalink)
Subject Memory allocation overflow
From jonas.thornvall@gmail.com

Show all headers | View raw


What could possibly overflow in this?

To me it seems just weird

j=1;
while(j<=base){
prime=false;
i=j;
i=i+base;
while (i<100){
 primeleg=factor_it(i);
 if(primeleg==true){break;}
 i=i+base;
}
outStr+="Base="+base+" counterval i = "+i+" P primeleg ="+primeleg+"\n";
j++;
}






The full code below------------------------
<script language="Javascript">

function factor_it(i){
prime=true;
sqroot=Math.floor(Math.sqrt(i));
for (j=2;j<sqroot;j++){ k=i/j; prime=!Number.isInteger(k); if (prime) {return prime}}
return prime;
}

function main(){
base=10;
outStr="";

//while (base==10) {

j=1;
while(j<=base){
prime=false;
i=j;
i=i+base;
while (i<100){
 primeleg=factor_it(i);
 if(primeleg==true){break;}
 i=i+base;
}
outStr+="Base="+base+" counterval i = "+i+" P primeleg ="+primeleg+"\n";
j++;
}

//base++;
//}
document.prime.out.value =outStr;
}
</script>
<!DOCTYPE html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>

<body onload="main()" bgcolor="gold">
<form name="prime" action="" onsubmit="MAIN(); return false;">
<textarea name="out" cols=80 rows=80></textarea>
</form>
</body>
</html>

Back to comp.lang.javascript | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Memory allocation overflow jonas.thornvall@gmail.com - 2016-01-16 09:58 -0800
  Re: Memory allocation overflow "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2016-01-16 19:52 +0100
    Re: Memory allocation overflow jonas.thornvall@gmail.com - 2016-01-16 11:03 -0800
      Re: Memory allocation overflow jonas.thornvall@gmail.com - 2016-01-16 11:05 -0800
        Re: Memory allocation overflow Luuk <luuk@invalid.lan> - 2016-01-16 20:13 +0100
          Re: Memory allocation overflow jonas.thornvall@gmail.com - 2016-01-16 11:25 -0800
            Re: Memory allocation overflow Luuk <luuk@invalid.lan> - 2016-01-16 21:25 +0100
              Re: Memory allocation overflow Luuk <luuk@invalid.lan> - 2016-01-16 21:31 +0100
                Re: Memory allocation overflow jonas.thornvall@gmail.com - 2016-01-16 14:06 -0800
                Re: Memory allocation overflow John Harris <niam@jghnorth.org.uk.invalid> - 2016-01-17 11:08 +0000
                Re: Memory allocation overflow jonas.thornvall@gmail.com - 2016-01-17 04:10 -0800
                Re: Memory allocation overflow Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-01-17 20:15 +0000
                Re: Memory allocation overflow jonas.thornvall@gmail.com - 2016-01-17 13:25 -0800
                Re: Memory allocation overflow Carlos Pedro <carlospedr@gmail.com> - 2016-01-18 08:21 -0800
      Re: Memory allocation overflow "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2016-01-16 20:29 +0100
  Re: Memory allocation overflow Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-01-16 23:43 +0000
    Re: Memory allocation overflow jonas.thornvall@gmail.com - 2016-01-16 19:30 -0800
      Re: Memory allocation overflow jonas.thornvall@gmail.com - 2016-01-16 19:56 -0800
        Re: Memory allocation overflow jonas.thornvall@gmail.com - 2016-01-16 20:01 -0800
  Re: Memory allocation overflow Silvio <silvio@internet.com> - 2016-01-18 16:09 +0100

csiph-web