Skip to content

Instantly share code, notes, and snippets.

@panchiga
Created October 6, 2013 06:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save panchiga/6850154 to your computer and use it in GitHub Desktop.
Save panchiga/6850154 to your computer and use it in GitHub Desktop.
def func(n)
return n+1
end
def Bpart(head,tail)
if ((head == 0)&&(tail > 0))
func(tail)
elsif ((head > 0)&&(tail==0))
Bpart(head-1,1)
else
tmpB = Bpart(head,tail-1)
Bpart(head-1,tmpB)
end
end
def g(n)
Bpart(n,n)
end
a = gets.to_i
puts g(a)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment