Back to Practice Dashboard
Python BasicsEasy
Find the prime numbers between 1 to 100
Learn how to solve the 'Find the prime numbers between 1 to 100' problem. This detailed resource details brute force and optimized approaches.
Problem Statement
Easy
Write a function primes_up_to_100() that takes no arguments and returns a list of all prime numbers between 1 and 100 (inclusive of 100 if it were prime).
A prime number is a number greater than 1 that has no divisors other than 1 and itself. The first few primes are 2, 3, 5, 7, 11, ...
Constraints
- •The range is fixed: 1 to 100
- •Return a list sorted in ascending order
Examples
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?
Use simple arithmetic operators (like modulo `%`, division `//`), conditional checks, or loops to inspect number properties.
Edge Cases to Watch
- Empty list or null input variables
- Single item lists/arrays
- Extremely large input bounds causing integer or stack overflow
Ready to Solve?
Open the problem in PyRun's browser-based Python editor. Your code runs fully offline — no server required.