ScratchData LogoScratchData
Back to gtoal's profile

Ackermann's Function the naive way

GTgtoal•Created October 2, 2014
Ackermann's Function the naive way
1
1
71 views
View on Scratch

Instructions

Ackermann's function is a recursive function (like factorial) which can't be easily rewritten in a non-recursive way (unlike factorial which is just a loop). It's an expensive function to calculate, and when written the simple way like this, some calls to the function take so long to complete that there's no point in doing them. Compare the code in this demo to the version in http://scratch.mit.edu/projects/28293808/ which uses a technique called 'memo functions' to remember previously computed results, allowing it to avoid most of the recursive calls and execute in far less time. This technique can be applied to any function where the same arguments always give the same results (ie no internal state. These are what computer scientists (but maybe not mathematicians) call 'idempotent' functions.)

Description

See http://en.wikipedia.org/wiki/Ackermann_function for an explanation of Ackermann's Function.

Project Details

Project ID28287344
CreatedOctober 2, 2014
Last ModifiedOctober 19, 2014
SharedOctober 19, 2014
Visibilityvisible
CommentsAllowed