+ 4

What is recursion ? ?

can u explain me ? in ruby ?

28th Oct 2017, 7:32 AM
~Sudo Bash
~Sudo Bash - avatar
5 Respuestas
28th Oct 2017, 8:23 AM
Valen.H. ~
Valen.H. ~ - avatar
+ 14
https://www.leighhalliday.com/recursion-in-ruby
28th Oct 2017, 7:37 AM
Dev
Dev - avatar
+ 5
A function that returns itself and has a base case. for example, let the base case, f(0) be 1 Then, you want to have f(1)=1, f(2)=2, f(3)=6, f+4)=24, you return n*f(n-1) A function sample: def fun(x) if x==0 return 1 else return fun(x-1)*x end end
28th Oct 2017, 7:50 AM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 2
Recursion, basically, means applying a code on a big thing, finding a smaller version of the big thing in the thing itself, then applying the same script to each smaller thing in the big thing. My best example is folder operations: If you recurse, you do the same operation on each folder within the folder itself.
28th Oct 2017, 7:45 AM
Claus G. Madsen
Claus G. Madsen - avatar
+ 1
if x == 1 then? ???
28th Oct 2017, 8:16 AM
~Sudo Bash
~Sudo Bash - avatar