#3770

Largest Prime from Consecutive Prime Sum

expert · 1035 · lc medium +32 · 38.9% accepted · 63 likes · top 18%

Description

Given an integer n, find and return the largest prime number that is at most n and can be written as the sum of one or more consecutive primes beginning with 2; if no such prime exists, return 0.

Code

1
2
3