Skip to content

Instantly share code, notes, and snippets.

@ynarwal
Last active August 25, 2015 22:54
Show Gist options
  • Save ynarwal/5804f5264385e4c20e14 to your computer and use it in GitHub Desktop.
Save ynarwal/5804f5264385e4c20e14 to your computer and use it in GitHub Desktop.
def nthterm(first, n, c)
# Write here !
if(n == 1)
first
end
if(first == 0)
nth = c + nthterm((first+c), (n-1), c)
else
nth = c * nthterm((first*c), (n-1), c)
end
nth
end
##It gives me stack level too deep
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment