Classic Computer Magazine Archive PROGRAM LISTING: 84-10/BIRTHDAY.LGO


TO BIRTHDAY.PROBLEM :PEOPLE
( PR BEGIN.SOLVING :PEOPLE 365 )
END


TO BEGIN.SOLVING :EVENTS :POSSIBILITIES
MAKE "PROBABILITY 1
OUTPUT SOLVE :EVENTS - 1 :POSSIBILITIES
END


TO SOLVE :EVENTS :POSSIBILITIES
MAKE "PROBABILITY :PROBABILITY * ( :POSSIBILITIES - :EVENTS ) / :POSSIBILITIES
IF :EVENTS = 0 [OUTPUT WORD 100 * ( 1 - :PROBABILITY ) "%]
OUTPUT SOLVE :EVENTS - 1 :POSSIBILITIES
END


Back to previous page