프로그래머스. 다음 큰 숫자 파이썬 풀이

minan·2021년 6월 29일
0

프로그래머스

목록 보기
80/92

프로그래머스. Level 2. 다음 큰 숫자 파이썬 풀이

문제링크 https://programmers.co.kr/learn/courses/30/lessons/12911

def solution(n):
    
    # n의 1의 개수
    one = bin(n)[2:].count('1')
    
    while 1:
        # n을 1씩 더하면서
        n += 1
        # 1의 개수가 같다면 그 수 리턴
        if one == bin(n)[2:].count('1'):
            return n
profile
https://github.com/minhaaan

0개의 댓글