Scroll indicator done
728x90

https://school.programmers.co.kr/learn/courses/30/lessons/12954

 

프로그래머스

코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.

programmers.co.kr

오류는 났지만,,, (아마 0일 때 if를 처리해줘야 할듯. 귀찮음)
list(range(x, (n+1)*x, x))
이런 식으로 가능!!
def solution(x, n):
    return [(i+1) * x  for i in range(n)]

https://school.programmers.co.kr/learn/courses/30/lessons/12934

 

프로그래머스

코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.

programmers.co.kr

import math

def solution(n):
    if int(math.sqrt(n)) == math.sqrt(n):
        return int(pow(math.sqrt(n)+1, 2))
    else: return -1

# 한줄로도 가능
def solution(n):
    return int(pow(math.sqrt(n)+1, 2)) if int(math.sqrt(n)) == math.sqrt(n) else -1

 

728x90