Велислав обнови решението на 13.10.2014 17:09 (преди около 10 години)
+def fibonacci(number)
+ return 1 if (1..2).include? number
+ fibonacci(number-1) + fibonacci(number-2) if number > 2
+end
+
+def lucas(number)
+ return 2 if number.eql?1
+ return 1 if number.eql?2
+ lucas(number-1)+ lucas(number-2) if number>1
+end
+
+def series (name , number)
+ return fibonacci(number) if name.eql? "fibonacci"
+ return lucas(number) if name.eql? "lucas"
+ return fibonacci(number) + lucas(number) if name.eql? "summed"
+end