Last active
January 25, 2023 19:13
-
-
Save zunda/ed6fb48973e8f02e8c636d3c173b6a3a to your computer and use it in GitHub Desktop.
拡張素数日
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
#!/usr/bin/ruby | |
# | |
# Copyright 2023 zunda <zundan at gmail.com> | |
# | |
# Permission is granted for use, copying, modification, distribution, | |
# and distribution of modified versions of this work as long as the | |
# above copyright notice is included. | |
# | |
require 'prime' | |
today = Time.now.localtime.strftime('%Y%m%d') | |
a = today.scan(/\d/).map{|i| i.to_i}.reverse | |
b = a.max + 1 | |
r = nil | |
while b < 100 | |
if a.map.with_index{|n,i| n*b**i}.sum.prime? | |
r = "今日#{today}は基数#{b}で素数だからがんばろう" | |
break | |
end | |
b += 1 | |
end | |
r ||= "今日#{today}は素数日じゃないかもしれない" | |
puts r |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment