diff options
Diffstat (limited to 'challenge-168/robert-dicicco/ruby')
| -rw-r--r-- | challenge-168/robert-dicicco/ruby/ch-1.rb | 37 |
1 files changed, 37 insertions, 0 deletions
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 }" |
