Algorithm/프로그래머스
[Lv.0/Python] 다음에 올 숫자
chocoji
2023. 7. 25. 23:33
🔗 문제
https://school.programmers.co.kr/learn/courses/30/lessons/120924
💻 Code
def solution(common):
a, b, c = common[:3]
if b - a == c - b: # 등차수열
return common[-1] + (b - a)
elif b // a == c // b: # 등비수열
return common[-1] * (b // a)