Skip to content

Instantly share code, notes, and snippets.

@hyuki0000
Created September 17, 2017 10:07
Show Gist options
  • Save hyuki0000/3d3682496bf56c8186d4f9b5d06de346 to your computer and use it in GitHub Desktop.
Save hyuki0000/3d3682496bf56c8186d4f9b5d06de346 to your computer and use it in GitHub Desktop.
小さい方からn個選んだ素数の平均が素数になることはn=1以外にあるかな?
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
@hyuki0000
Copy link
Author

20170917185437

@hyuki0000
Copy link
Author

この話題のツイートはこちらからたどれます
https://twitter.com/hyuki/status/909338738202775554

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment