Created
September 17, 2017 10:07
-
-
Save hyuki0000/3d3682496bf56c8186d4f9b5d06de346 to your computer and use it in GitHub Desktop.
小さい方からn個選んだ素数の平均が素数になることはn=1以外にあるかな?
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
require 'prime' | |
MAX = 10000_00000_00000 | |
n = Rational(0) | |
s = Rational(0) | |
Prime.each(MAX) do |p| | |
n += 1 | |
s += p | |
if (s/n).denominator == 1 | |
puts "f(#{n}) = #{s/n} : INTEGER" | |
if Prime.prime?((s/n).to_i) | |
puts "f(#{n}) = #{s/n} : PRIME" | |
end | |
end | |
if n % 100000 == 0 | |
print "(#{n})\r" | |
end | |
end |
Author
hyuki0000
commented
Sep 17, 2017
この話題のツイートはこちらからたどれます
https://twitter.com/hyuki/status/909338738202775554
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment