Demo entry 6645674

Ackermann Function written in Ruby

   

Submitted by anonymous on Oct 11, 2017 at 08:40
Language: Ruby. Code size: 195 Bytes.

def ackermann(m, n)
  return n + 1 if m == 0
  return ackermann(m - 1, 1) if m > 0 && n == 0
  return ackermann(m - 1, ackermann(m, n - 1))
end

puts "ackermann(#{4}, #{1}) = #{ackermann(4, 1)}"

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).