Anonymous user
Birthday problem: Difference between revisions
→{{header|REXX}}: re-worked entire program. -- ~~~~
Walterpachl (talk | contribs) m (→{{header|PL/I}}: typo) |
(→{{header|REXX}}: re-worked entire program. -- ~~~~) |
||
Line 198:
if samp=='' | samp==',' then samp=100000 /*" " " " " */
if seed\==',' & seed \=='' then call random ,,seed /*repeatability? */
/* [
do
do samp;
@.day=
if @.day=
s=s+j
end /*samp*/▼
end /*
pad=' ' /*padding for easier eyeballing. */▼
say ' sample size is ' samp /*show sample size of this run. */
say
say
say
say ___ '────────' ___ '─────' ___ '────────────────'▼
/* [↓] where the try-outs happen.*/
do g=2 to grps /*perform through 2──►group size.*/
do try=start.g; s=0 /*perform try-outs until avg>50%.*/
do samp; @.=0 /*perform some number of trials. */
do j=1 for try /*do until K dup birthdays found.*/
day=random(1,diyM) % 100 /*expand random number generation*/
@.day=@.day+1 /*record the of a particular Bday*/
if @.day\==g then iterate /*when G hits have occurred ···*/
leave /* ... and stop looking for more.*/
end /*j*/
say
end /*g*/
/*stick a fork in it, we're done.*/</lang>
'''output'''
Line 230 ⟶ 243:
sample size is 100000
required group % with required
common size common birthdays
▲ ──────── ───── ────────────────
2
3 88
4 187 50.
5
</pre>
|