주어진 수까지의 곱
arr = input().split()
a,b = int(arr[0]), int(arr[1])
prod = 1
for i in range(a, b+1):
prod *= i
print(prod)
a의 b승
https://www.codetree.ai/trails/complete/curated-cards/challenge-a-to-the-power-of-b/description
arr = input().split()
a,b = int(arr[0]), int(arr[1])
prod = 1
for _ in range(b):
prod *= a
print(prod)
출력결과 41
https://www.codetree.ai/trails/complete/curated-cards/challenge-reading-k201714/description
0
a의 배수들의 곱
https://www.codetree.ai/trails/complete/curated-cards/test-product-of-multiples-of-a/description
arr = input().split()
a,b = int(arr[0]), int(arr[1])
prod = 1
for i in range(1, b+1):
if i % a == 0:
prod *= i
print(prod)
'코딩테스트 > 프로그래밍 기초 | 단순 반복문' 카테고리의 다른 글
[코드트리] break문 (1) | 2025.01.21 |
---|---|
[코드트리] continue문 (0) | 2025.01.17 |
[코드트리] sum 계산하기 (1) | 2025.01.09 |
[코드트리] cnt 활용하기 (0) | 2025.01.08 |
[코드트리] 반복문 안의 if (0) | 2025.01.03 |