Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
23
Task/Ackermann-function/Eiffel/ackermann-function.e
Normal file
23
Task/Ackermann-function/Eiffel/ackermann-function.e
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
class
|
||||
ACKERMAN_EXAMPLE
|
||||
|
||||
feature -- Basic Operations
|
||||
|
||||
ackerman (m, n: NATURAL): NATURAL
|
||||
-- Recursively compute the n-th term of a series.
|
||||
require
|
||||
non_negative_m: m >= 0
|
||||
non_negative_n: n >= 0
|
||||
do
|
||||
if m = 0 then
|
||||
Result := n + 1
|
||||
elseif m > 0 and n = 0 then
|
||||
Result := ackerman (m - 1, 1)
|
||||
elseif m > 0 and n > 0 then
|
||||
Result := ackerman (m - 1, ackerman (m, n - 1))
|
||||
else
|
||||
check invalid_arg_state: False end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue