3770. Largest Prime from Consecutive Prime Sum
You are given an integer n. Return the largest prime number less than or equal to n that can be expressed as the sum of one or more consecutive prime numbers starting from 2. If no such number exists, return 0. Example 1: Input: n = 20 Output: 17 Explanation: The prime numbers less than or equal to n = 20 which are consecutive prime sums are: - 2 = 2 - 5 = 2 + 3 - 17 = 2 + 3 + 5 + 7
HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17
CodeSearch Tutor
Hints, not spoilers — it won’t hand over the full solution unless you insist.
Sign in to chat with the tutor and save your progress.
Sign in to start