L0 : 연속된 수의 합 Python

jhyunn·2023년 1월 11일
0

Programmers

목록 보기
3/69

L0 : 연속된 수의 합 Python

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

def solution(num, total):
    if total%num==0:
        return list(range(total//num - num//2, total//num + num//2+1))
    else:
        return list(range(total//num - num//2+1, total//num + num//2+1))

주어진 total을 num으로 나누면 중간에 위치할 수가 나온다.

profile
https://github.com/Sungjeonghyun

0개의 댓글