Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Man or boy test
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Knuth's example== In [[ALGOL 60]]: <syntaxhighlight lang="Pascal"> begin real procedure A(k, x1, x2, x3, x4, x5); value k; integer k; real x1, x2, x3, x4, x5; begin real procedure B; begin k := k - 1; B := A := A(k, B, x1, x2, x3, x4) end; if k β€ 0 then A := x4 + x5 else B end; outreal(1, A(10, 1, -1, -1, 1, 0)) end </syntaxhighlight> This creates a tree of ''B'' call frames that refer to each other and to the containing ''A'' call frames, each of which has its own copy of ''k'' that changes every time the associated ''B'' is called. Trying to work it through on paper is probably fruitless, but for ''k'' = 10, the correct answer is β67, despite the fact that in the original article Knuth conjectured it to be β121. Even modern machines quickly run out of [[call stack|stack]] space for larger values of ''k'', which are tabulated below ({{OEIS2C|A132343}}). {| class="wikitable" style="text-align:right" ! {{mvar|k}} ! {{tmath|A(k, 1, -1, -1, 1, 0)}} |- | 0 | 1 |- | 1 | 0 |- | 2 | β2 |- | 3 | 0 |- | 4 | 1 |- | 5 | 0 |- | 6 | 1 |- | 7 | β1 |- | 8 | β10 |- | 9 | β30 |- | 10 | β67 |- | 11 | β138 |- | 12 | β291 |- | 13 | β642 |- | 14 | {{val|β1,446}} |- | 15 | {{val|β3,250}} |- | 16 | {{val|β7,244}} |- | 17 | {{val|β16,065}} |- | 18 | {{val|β35,601}} |- | 19 | {{val|β78,985}} |- | 20 | {{val|β175,416}} |- | 21 | {{val|β389,695}} |- | 22 | {{val|β865,609}} |- | 23 | {{val|β1,922,362}} |- | 24 | {{val|β4,268,854}} |- | 25 | {{val|β9,479,595}} |- | 26 | {{val|β21,051,458}} |}
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)