diff options
Diffstat (limited to 'challenge-150/robert-dicicco/ruby/ch-1.rb')
| -rw-r--r-- | challenge-150/robert-dicicco/ruby/ch-1.rb | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/challenge-150/robert-dicicco/ruby/ch-1.rb b/challenge-150/robert-dicicco/ruby/ch-1.rb new file mode 100644 index 0000000000..57459d2a14 --- /dev/null +++ b/challenge-150/robert-dicicco/ruby/ch-1.rb @@ -0,0 +1,32 @@ +#!ruby.exe + +# Author: Robert DiCicco +# Date: 31-JAN-2022 +# Challenge 150 Fibonacci Words (Ruby) + +a = '1234' +b = '5678' + +# recursive routine to create fibonacci series, but using strings + +def Fib ( first, second) + val = first + second + puts val + + # if new string length is less than 51, go another round using new combined string + if val.length < 51 then + Fib( second, val) + else + # return the string if length 51 or greater + return val + end + +end + +puts 'Fibonacci Words' +puts a +puts b + +# get the 51st character +char = Fib(a,b)[50].chr +puts "51st digit is " + char |
