1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

コマンドラインから入力した数値が3で割り切れるか教えてくれるプログラム(Python)

Posted at

コマンドラインから入力した数値が3で割り切れるか教えてくれるプログラムをPython言語で紹介します。

以下ソースコードです。

text = input()
data = 0

for s in text:
    data += int(s)

if data%3 == 0: print("3で割り切れます!")
if data%3 != 0: print("3で割り切れません!")

実行結果

3
3で割り切れます!

333333333333333333333333333333333333333333333333333
3で割り切れます!

12
3で割り切れます!

14
3で割り切れません!

18
3で割り切れます!

300000000000000000000
3で割り切れます!

30000000000000000000000000000000000000001
3で割り切れません!

3000000000000000000000000000000000003
3で割り切れます!

19238902138902180321380921903812013812903021380
3で割り切れます!

1
0
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?