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


Groups > comp.lang.javascript > #40870

Re: Random numbers

From John Harris <niam@jghnorth.org.uk.invalid>
Newsgroups comp.lang.javascript
Subject Re: Random numbers
Date 2022-05-18 18:29 +0100
Organization A noiseless patient Spider
Message-ID <t63ad8$m7h$1@dont-email.me> (permalink)
References <osa2ld$6t0$1@gioia.aioe.org> <4f747cef-38ab-4cbe-886a-52f50e80819en@googlegroups.com> <t5o0hq$umk$1@dont-email.me> <01ecfd5e-500a-4eda-a86e-3d91877a4814n@googlegroups.com>

Show all headers | View raw


On 15/05/2022 10:51, Mister Kristjan wrote:
> John Harris kirjutas Laupäev, 14. mai 2022 kl 12:33:38 UTC+2:
>> On 14/05/2022 07:14, First name Last name wrote:
>>> You don't need to get random numbers with a program. You create random numbers with your brain.
>> Many experiments have shown that human brains are very bad at creating
>> "random" numbers.
>>
>> John
> 
> Okey, try then this
> |
> |
> |
> |
> V
> 
> 
> <html>
> <body>
> <div id="aa1" style="width: 100%;word-break:break-word;">
> </div>
> <script>
> var a1=Math.random()*106875;
> a1=Math.round(a1*100000000000)/1000000000000;
> for(var i=0; i<9876; i++) {
> var i01=i*0.1342626246475681396246346+i*0.267629578752464837134+0.13257568494264346234;
> a1=a1*a1*0.263856787598547681531;
> if(a1<0.1) a1=a1+4.37469234896;
> if(a1>100000) a1=a1*0.000004398734756825426923475896;
> var j=a1*2.4326974639679758456872875*i01;
> j=Math.round(j*100000000000)/100000000000;
> document.getElementById("aa1").append(j);
> }
> var aa001=document.getElementById("aa1").innerHTML;
> aa001=aa001.replace(/\./g,'');
> aa001=aa001.replace(/\+/g,'');
> aa001=aa001.replace(/e/g,'');
> aa001=aa001.replace(/\-/g,'');
> document.getElementById("aa1").innerHTML=aa001;
> </script>
> 
> </body>
> </html>
> 


Here's a simpler version :-

<html>

<title> Random digits </title>

<body>
<div id="aa1" style="width: 100%;word-break:break-word;">
</div>

<script>
	var s = "";  // Random digit sequence

	for(var i = 0; i<160000; i++)
	  {
		var d = Math.floor(10*Math.random());
		if (d < 10)  // In case random = 1.0 (Shouldn't be)
		  s += d;
	  }
	
	document.getElementById("aa1").innerHTML = s;
	
</script>

</body>
</html>


   John

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


Thread

Re: Random numbers First name Last name <he1291983@gmail.com> - 2022-05-13 23:14 -0700
  Re: Random numbers John Harris <niam@jghnorth.org.uk.invalid> - 2022-05-14 11:33 +0100
    Re: Random numbers Mister Kristjan <he1291983@gmail.com> - 2022-05-15 02:51 -0700
      Re: Random numbers John Harris <niam@jghnorth.org.uk.invalid> - 2022-05-18 18:29 +0100
        Re: Random numbers Jon Ribbens <jon+usenet@unequivocal.eu> - 2022-05-18 20:38 +0000
          Re: Random numbers Ingel <he12091983@gmail.com> - 2022-05-29 09:12 -0700
            Re: Random numbers John Harris <niam@jghnorth.org.uk.invalid> - 2022-05-29 18:05 +0100
            Re: Random numbers V V V V V <ya00000100000@worker.com> - 2023-01-15 02:05 -0800
              Re: Random numbers V <vvvvvvvvvvvvvv@mail.ee> - 2023-08-14 23:24 -0700
              Re: Random numbers V <vvvvvvvvvvvvvv@mail.ee> - 2023-08-14 23:28 -0700
               ⠀ ⠀ ⠀ ⠀ ⠀ ⠀ ⠀ ⠀ ⠀ ⠀N⠀u⠀m⠀b⠀r⠀i⠀d ⠀ ⠀ ⠀ ⠀ ⠀ ⠀ ⠀ ⠀ ⠀ ⠀ ⠀ ⠀ ⠀ ⠀ ⠀ ⠀ ⠀ ⠀ ⠀ ⠀ ⠀ ⠀ ⠀ ⠀ ⠀ ⠀ ⠀ ⠀ ⠀ ⠀ ⠀ ⠀ ⠀ ⠀ ⠀ ⠀ ⠀ ⠀ ⠀ V <vvvvvvvvvvvvvv@mail.ee> - 2023-08-14 23:53 -0700
              Re: Random numbers V <vvvvvvvvvvvvvv@mail.ee> - 2023-08-15 00:05 -0700
              Re: Random numbers V <vvvvvvvvvvvvvv@mail.ee> - 2023-08-16 22:44 -0700
              Re: Random numbers V <vvvvvvvvvvvvvv@mail.ee> - 2023-08-16 22:51 -0700
    Re: Random numbers Mister Kristjan <he1291983@gmail.com> - 2022-05-15 02:57 -0700

csiph-web