0
0

More than 1 year has passed since last update.

paizaラーニング「任意の数で何回割れる? Python3編」

Posted at

https://paiza.jp/works/mondai/loop_problems2/loop_problems2__div_m
私の回答

N,M = map(int,input().split())

div_count = 0
while True:
    if N % M == 0:
        N //= M
        div_count += 1
    else:
        break

print(div_count)

模範解答

N, M = map(int, input().split())

div_count = 0
while True:
    if N % M == 0:
        N //= M
        div_count += 1
    else:
        break

print(div_count)

2で何回割れるの模範解答を基に、今回の回答を作ったので、ほぼ同じ回答になりました。

0
0
1

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
0
0