Даяна обнови решението на 11.10.2014 23:33 (преди около 10 години)
+def series(string, number)
+ string == "fibonacci" ? fibonacci(number)
+ : string == "lucas" ? lucas(number) : summed(number)
+end
+
+def fibonacci(number)
+ number <= 1 ? number : fibonacci(number - 1) + fibonacci(number - 2)
+end
+
+def lucas(number)
+ if number == 1
+ 2
+ elsif number == 2
+ 1
+ else lucas(number - 1) + lucas(number - 2)
+ end
+end
+
+def summed(number)
+ fibonacci(number) + lucas(number)
+end