--- title: "Birthday" id: 57637 type: "computer_media" slug: "october-1983-loader" url: "http://localhost/computer_media/october-1983-loader/" markdown_url: "http://localhost/computer_media/october-1983-loader.md" published_at: "2024-10-06T01:07:18+00:00" modified_at: "2026-03-30T21:16:43+00:00" author: "David Anderson" featured_image: url: "http://localhost/wp-content/uploads/2024/10/birthday-calc.png" excerpt: "A compact Birthday Problem solver that streams 60 probability values, revealing exactly when shared birthdays become more likely than not." category: - name: "Archived Media" slug: "archived-media" taxonomy: "category" url: "http://localhost/category/archived-media/" post_tag: - name: "Downloadable" slug: "downloadable" taxonomy: "post_tag" url: "http://localhost/tag/downloadable/" - name: "TS 1000" slug: "ts1000" taxonomy: "post_tag" url: "http://localhost/tag/ts1000/" model: - name: "Timex/Sinclair 1000" slug: "ts-1000" taxonomy: "model" url: "http://localhost/model/ts-1000/" indiv: - name: "Gene G. Buza" slug: "gene-g-buza" taxonomy: "indiv" url: "http://localhost/indiv/gene-g-buza/" genre: - name: "Entertainment" slug: "entertainment" taxonomy: "genre" url: "http://localhost/type/entertainment/" media_contents: - id: 56727 title: "Synchro-Sette October 1982" type: "computer_media" url: "http://localhost/computer_media/synchro-sette-october-1982/" media_type: "Program" programmers: - name: "Gene G. Buza" slug: "gene-g-buza" taxonomy: "indiv" url: "http://localhost/indiv/gene-g-buza/" mediadate: "October 1982" images: - url: "http://localhost/wp-content/uploads/2024/10/birthday-calc.png" media_type_tags: "Entertainment, Software" --- # Birthday This program calculates the “Birthday Problem” probabilities, determining how many people are needed in a group before there is at least a 50% chance that two or more share the same birthday. It iterates from 1 to 60 people, printing each group size alongside the running probability that at least two share a birthday. The probability complement is computed iteratively: Q accumulates the product of (365−N)/365 terms, representing the chance that all birthdays are distinct, and then (Q−1)×−100 converts this to a percentage chance of a collision. The SCROLL command is used to prevent the display from pausing, allowing all 60 results to stream continuously past. *** ## Program Analysis ### Program Structure The program is a straightforward iterative calculation across six lines. It initialises a probability accumulator, loops from 1 to 60, and prints results continuously using `SCROLL` to avoid the display filling up. | Line | Purpose | | --- | --- | | `10` | Prints a multi-line description of the problem | | `20` | Initialises `Q` to 1 (the probability all birthdays are unique, starting condition) | | `30` | Opens the main loop, `N` = group size from 1 to 60 | | `40` | `SCROLL` prevents the display from pausing between lines | | `50` | Prints `N` and the collision probability as a percentage | | `60` | Updates `Q` by multiplying in the next distinct-birthday factor | | `70` | Closes the loop | ### Mathematical Approach The Birthday Problem is solved using the complementary probability. `Q` holds the probability that all `N` people have distinct birthdays, computed as the running product: `Q = (365/365) × (364/365) × (363/365) × … × ((365−N+1)/365)` At each step, line `50` prints `-(100*(Q-1))`, which is equivalent to `100*(1-Q)` — converting the complement probability into a percentage chance that at least two people share a birthday. The negation trick avoids the need for a separate subtraction from 1, since `Q−1` is always negative or zero. The classic result — that a group of 23 people suffices for a greater than 50% collision probability — will be clearly visible in the output around `N=23`. ### Key BASIC Idioms - `SCROLL` at line `40` suppresses the scroll prompt, allowing all 60 lines of output to flow without user intervention. - The use of commas in the `PRINT` statement at line `10` advances to successive print zones, indenting the title text. - The expression `-(100*(Q-1))` is a compact idiom for `100*(1-Q)`, exploiting unary negation rather than rewriting the subtraction. - `Q` is updated in place each iteration rather than recomputed from scratch, making this an efficient incremental calculation. ### Notable Techniques The iterative update of `Q` at line `60` — multiplying by `(365-N)/365` — means the program never needs to compute a factorial or large product from scratch, keeping numerical operations within manageable floating-point range for all 60 iterations. ### Bugs and Anomalies The loop begins at `N=1`, for which the collision probability is 0% (one person cannot share a birthday with anyone else). This is mathematically correct but slightly redundant as a starting point. The loop runs to `N=60`, well past the point (~23) where probability exceeds 50%, which is useful for demonstrating how quickly the probability approaches certainty near `N=60` (approximately 99.4%). The title string on line `10` is not line-wrapped with explicit formatting — the text runs on as a single long string and relies on the display’s automatic wrapping, which may produce ragged output depending on screen width. ## Source Code ``` 10 PRINT ,,"PROGRAM TO DETERMINE THE NUMBER OF PEOPLE NEEDED TO HAVE AT LEAST 50 PERCENT PROBABILITY OF HAVING TWO OR MORE WITH THE SAMEBIRTHDAY." 20 LET Q=1 30 FOR N=1 TO 60 40 SCROLL 50 PRINT N,-(100*(Q-1)) 60 LET Q=Q*(365-N)/365 70 NEXT N ```