Skip to content

Commit a9e2ae9

Browse files
committed
Create README - LeetHub
1 parent a38b5e0 commit a9e2ae9

File tree

1 file changed

+49
-0
lines changed
  • 3770-largest-prime-from-consecutive-prime-sum

1 file changed

+49
-0
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<h2><a href="https://leetcode.com/problems/largest-prime-from-consecutive-prime-sum">4085. Largest Prime from Consecutive Prime Sum</a></h2><h3>Medium</h3><hr><p>You are given an integer <code>n</code>.</p>
2+
3+
<p>Return the <strong>largest <span data-keyword="prime-number">prime number</span></strong> less than or equal to <code>n</code> that can be expressed as the <strong>sum</strong> of one or more <strong>consecutive prime numbers</strong> starting from 2. If no such number exists, return 0.</p>
4+
5+
<p>&nbsp;</p>
6+
<p><strong class="example">Example 1:</strong></p>
7+
8+
<div class="example-block">
9+
<p><strong>Input:</strong> <span class="example-io">n = 20</span></p>
10+
11+
<p><strong>Output:</strong> <span class="example-io">17</span></p>
12+
13+
<p><strong>Explanation:</strong></p>
14+
15+
<p>The prime numbers less than or equal to <code>n = 20</code> which are consecutive prime sums are:</p>
16+
17+
<ul>
18+
<li>
19+
<p><code>2 = 2</code></p>
20+
</li>
21+
<li>
22+
<p><code>5 = 2 + 3</code></p>
23+
</li>
24+
<li>
25+
<p><code>17 = 2 + 3 + 5 + 7</code></p>
26+
</li>
27+
</ul>
28+
29+
<p>The largest is 17, so it is the answer.</p>
30+
</div>
31+
32+
<p><strong class="example">Example 2:</strong></p>
33+
34+
<div class="example-block">
35+
<p><strong>Input:</strong> <span class="example-io">n = 2</span></p>
36+
37+
<p><strong>Output:</strong> <span class="example-io">2</span></p>
38+
39+
<p><strong>Explanation:</strong></p>
40+
41+
<p>The only consecutive prime sum less than or equal to 2 is 2 itself.</p>
42+
</div>
43+
44+
<p>&nbsp;</p>
45+
<p><strong>Constraints:</strong></p>
46+
47+
<ul>
48+
<li><code>1 &lt;= n &lt;= 5 * 10<sup>5</sup></code></li>
49+
</ul>

0 commit comments

Comments
 (0)