From ac32e51ae34212cd68b2cfdd8f72f54681006e29 Mon Sep 17 00:00:00 2001 From: Mohammad S Anwar Date: Tue, 7 Jun 2022 18:13:36 +0100 Subject: - Added solutions by Robert DiCicco. --- challenge-168/robert-dicicco/ruby/ch-1.rb | 37 +++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 challenge-168/robert-dicicco/ruby/ch-1.rb (limited to 'challenge-168/robert-dicicco/ruby/ch-1.rb') diff --git a/challenge-168/robert-dicicco/ruby/ch-1.rb b/challenge-168/robert-dicicco/ruby/ch-1.rb new file mode 100644 index 0000000000..0a050d6120 --- /dev/null +++ b/challenge-168/robert-dicicco/ruby/ch-1.rb @@ -0,0 +1,37 @@ +#!ruby.exe + +# AUTHOR: Robert DiCicco +# DATE: 2022-06-06 +# Challenge 168 Perrin Primes ( Ruby ) + +require 'prime' + +perrin = Array[3,0,2] + +PRIME_COUNT = 14 + +results = Array.new() + +i = 0 + +while i < PRIME_COUNT + + slots = perrin.length() + + calc_val = perrin[slots - 2] + perrin[slots - 3] + + perrin.push(calc_val) + + if Prime.prime?(calc_val) + + results.push(calc_val) + + i += 1 + + end + +end + +results = results.sort.uniq + +puts "#{results }" -- cgit