Skip to content

Instantly share code, notes, and snippets.

@k14i
Last active December 27, 2015 11:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save k14i/7318962 to your computer and use it in GitHub Desktop.
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.
# -*- 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