Python 기본 사항쉬움

1에서 100 사이의 소수 찾기

'1에서 100 사이의 소수 찾기' 문제에 대한 자세한 가이드 및 Python 구현입니다.

문제 설명

쉬움

인수를 사용하지 않고 1에서 100(소수인 경우 100 포함) 사이의 모든 소수 목록을 반환하는 함수 primes_up_to_100()을 작성하세요.

소수란 1과 자기 자신 외에 약수가 없는 1보다 큰 수를 말합니다. 처음 몇 개의 소수는 2, 3, 5, 7, 11, ...

제약
  • The range is fixed: 1 to 100
  • Return a list sorted in ascending order

Example 1
Input
primes_up_to_100()
Output
[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]
Explanation

There are 25 prime numbers between 1 and 100. Each number in the list is only divisible by 1 and itself.

Example 2
Input
len(primes_up_to_100())
Output
25
Explanation

The total count of primes between 1 and 100 is 25.

Need a Hint?
세트나 힙과 같은 Numbers 관련 데이터 구조를 사용해 보세요.
Edge Cases to Watch
  • 빈 입력 구조
  • 단일 요소 입력
  • 큰 수치 범위

해결할 준비가 되셨나요?

Open the problem in PyRun's browser-based Python editor. Your code runs fully offline — no server required.

편집기에서 열기
Found this breakdown helpful?

PyRun is built and maintained by an independent solo developer. If this helped your interview prep, consider buying a coffee!

Buy me a coffee

권장 Python 리소스

관련 대화형 튜토리얼, 치트 시트, 코드 비교를 통해 지식을 확장하세요.