Skip to content

Instantly share code, notes, and snippets.

@trickart
Last active December 30, 2015 06:09
Show Gist options
  • Save trickart/7787671 to your computer and use it in GitHub Desktop.
Save trickart/7787671 to your computer and use it in GitHub Desktop.
入力した数字が3の倍数か3の付く数字の時に「Nabeatsu」と返すだけのプログラム。
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