Skip to main content

Practice · 3 of 3

Totient Sums

CHALLENGE
Difficulty: advanced+25 XP

**Problem.** Line 1: q. Each line: N. Print sum_{k=1..N} phi(k) mod 1e9+7. **Constraints:** 1 ≤ q ≤ 2000; 1 ≤ N ≤ 10^6. Linear phi sieve + prefix sums once, then O(1) per query.

Back to lesson: Practice: Number Trio