Algorithm/Programmers
[프로그래머스/python3] Level 1 x만큼 간격이 있는 n개의 숫자 문제풀이
찐무
2021. 1. 25. 21:16
728x90
반응형

문제
programmers.co.kr/learn/courses/30/lessons/12954
코딩테스트 연습 - x만큼 간격이 있는 n개의 숫자
함수 solution은 정수 x와 자연수 n을 입력 받아, x부터 시작해 x씩 증가하는 숫자를 n개 지니는 리스트를 리턴해야 합니다. 다음 제한 조건을 보고, 조건을 만족하는 함수, solution을 완성해주세요.
programmers.co.kr
함수 solution은 정수 x와 자연수 n을 입력받아, x부터 시작해 x씩 증가하는 숫자를 n개 지니는 리스트를 리턴해야 합니다.
다음 제한 조건을 보고, 조건을 만족하는 함수, solution을 완성해주세요.
<정답>
This file contains hidden or 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
def solution(x, n): | |
result = [] | |
for i in range(1, n+1): | |
result.append(x*i) | |
return result |
728x90
반응형