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


Groups > comp.lang.javascript > #29269

Re: Found a bug in javascript see what it printout

Newsgroups comp.lang.javascript
Date 2016-01-16 15:24 -0800
References <4ab38ff8-e97b-43cb-9077-b5ca6ee23ea1@googlegroups.com>
Message-ID <ab9028a9-0ee4-41ca-aefc-d01e0fb008fa@googlegroups.com> (permalink)
Subject Re: Found a bug in javascript see what it printout
From jonas.thornvall@gmail.com

Show all headers | View raw


Den söndag 17 januari 2016 kl. 00:15:02 UTC+1 skrev jonas.t...@gmail.com:
> <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) {
> prime=false;
> primeleg=false;
> j=1;
> 
> while(j<base){
> 
> i=j;
> i=i+base;
> while (i<100){
> 
> // primeleg=factor_it(i);
>  if(primeleg==true){break;}
>  i=i+base;
> }
> j++;
> outStr+="Base="+base+" counterval i = "+ i +" P primeleg ="+primeleg+"\n";
> }
> 
> //base++;
> //}
> document.prima.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="prima" action="" onsubmit="MAIN(); return false;">
> <textarea name="out" cols=80 rows=80></textarea>
> <textarea name="trash" cols=80 rows=80></textarea>
> </form>
> </body>
> </html>

Bug resolved it was in brain double use of j in two loops.

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


Thread

Found a bug in javascript see what it printout jonas.thornvall@gmail.com - 2016-01-16 15:14 -0800
  Re: Found a bug in javascript see what it printout jonas.thornvall@gmail.com - 2016-01-16 15:24 -0800
  Re: Found a bug in javascript see what it printout "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2016-01-16 16:05 -0800
  Re: Found a bug in javascript see what it printout "Chris M. Thomasson" <nospam@nospam.nospam> - 2016-01-17 11:42 -0800
    Re: Found a bug in javascript see what it printout Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-01-18 19:59 +0100
      Re: Found a bug in javascript see what it printout "Chris M. Thomasson" <nospam@nospam.nospam> - 2016-01-18 11:19 -0800

csiph-web