Last active
December 27, 2015 11:29
-
-
Save k14i/7318962 to your computer and use it in GitHub Desktop.
Just to show a prime number of thirty one in a DRY way without any numerics.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
require 'prime' | |
arr = [] | |
n = Prime.first ** nil.to_i | |
foo = Proc.new {|x| x.times do n = Prime.first(n).last end } | |
bar = Proc.new {|x| arr << [[x] * x] } | |
Prime.first.times do |i| bar.call(Prime.first ** i) end | |
arr.flatten.map {|x| foo.call(x)} | |
puts n |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment