Anonymous user
Birthday problem: Difference between revisions
m
→version 1: added/changed comments and whitespace, used a template for the output section. optimized parts of the code.
m (added whitespace to the task's preamble, added text description to the (;See also) link.) |
m (→version 1: added/changed comments and whitespace, used a template for the output section. optimized parts of the code.) |
||
Line 1,265:
=={{header|REXX}}==
===version 1===
The method used is to find the average number of people to share a
<br>
<br>50%
<lang rexx>/*REXX
parse arg
if
if samp=='' | samp==
if datatype(seed, 'W')
diy =365
diyM=diy*100 /*this expands the RANDOM (BIF) range.*/
do g=2 to dups;
@.day=
say '
say ' duplicates size common birthdays'
say ' ──────────── ─────── ──────────────────'
▲say right('sample size is ' samp,40); say /*display this run's sample size. */
do try; day=random(1, diyM) %
end
end
▲ end /*try;*/ /* [↓] bump the counter for Bday hits.*/
▲ end /*samp*/
▲ end /*try=start.g*/
▲ say right(g, 15) right(try, 15) center( format(s/samp*100,,5)'%', 30)
▲'''output''' when using the input of: <tt> 10 </tt>
<pre>
sample size is
required
──────────── ─────── ──────────────────
2 23 50.
3
4 187 50.
5
6
7
8 798 50.
9
10
</pre>
|