Last active
December 30, 2015 06:09
-
-
Save trickart/7787671 to your computer and use it in GitHub Desktop.
入力した数字が3の倍数か3の付く数字の時に「Nabeatsu」と返すだけのプログラム。
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
a = ARGV[0].to_i | |
if a % 3 == 0 | |
print "Nabeatsu" | |
else | |
while a >= 10 | |
c = a | |
b = 0 | |
while c >= 10 | |
c /= 10 | |
b += 1 | |
end | |
if c == 3 | |
print "Nabeatsu" | |
exit | |
end | |
a = a - c * 10 ** b | |
end | |
if a == 3 | |
print "Nabeatsu" | |
else | |
print "Not Nabeatsu" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment