Sha256: c49ca49a803d9bfae852e2ba6fefb7b3f94c4a284e67d1bd7cd5085967cabf20
Contents?: true
Size: 290 Bytes
Versions: 20
Compression:
Stored size: 290 Bytes
Contents
class Integer def proth? return false if self < 3 n_max = Math.log2(self-1).ceil (1..(self / n_max)).select{|k| k.odd?}.any? do |k| (1..n_max).select{|n| 2**n > k}.any? do |n| break if (x = (k * (2**n)) + 1) > self x == self end end end end
Version data entries
20 entries across 20 versions & 1 rubygems