Algorithms Playbook
← All problems
MediumPrimes, GCD & fast power →Similar to: Count Primes

How many primes?

Problem

Given an integer n, return the number of prime numbers strictly less than n.

Examples

Input: n = 10

Output: 4

2, 3, 5, 7.

Input: n = 2

Output: 0

Hints

    Try it first. Every hint reveals a bit more.

    Solution