София обнови решението на 15.10.2014 13:35 (преди около 10 години)
+def fibonacci(number)
+ return number if number <= 1
+ fibonacci(number - 1) + fibonacci(number - 2)
+end
+
+def lucas(number)
+ return 2 if number == 1
+ return 1 if number == 2
+ lucas(number - 1) + lucas(number - 2)
+end
+
+def summed(number)
+ fibonacci(number) + lucas(number)
+end
+
+def series(sequence, number)
+ return fibonacci(number) if sequence == 'fibonacci'
+ return lucas(number) if sequence == 'lucas'
+ return summed(number) if sequence == 'summed'
+end