From ea530bc5cf89e42ab0175eec72b2ebccfa3fdad4 Mon Sep 17 00:00:00 2001 From: Mohammad S Anwar Date: Wed, 2 Feb 2022 17:16:00 +0000 Subject: - Added solutions by Robert DiCicco. --- challenge-150/robert-dicicco/ruby/ch-1.rb | 32 +++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 challenge-150/robert-dicicco/ruby/ch-1.rb (limited to 'challenge-150/robert-dicicco/ruby/ch-1.rb') 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 -- cgit