Comments on Prime Difference
Post
Prime Difference
Given an integer n, output the smallest prime such that the difference between it and the next prime is at least n.
For example, if n=5
, you would output 23
, since the next prime is 29
, and 29-23>=5
.
More Input/Output Examples
1 -> 2 (3 - 2 >= 1)
2 -> 3 (5 - 3 >= 2)
3 -> 7 (11 - 7 >= 3)
4 -> 7
5 -> 23
6 -> 23
7 -> 89
8 -> 89
This is code-golf, so shortest code wins.
[Husk], 8 bytes Ψḟo≥⁰≠İ …
4y ago
[Dyalog APL Extended], 14 byte …
4y ago
[Raku], 33 bytes {1 …
4y ago
Ruby, 56 bytes ```ruby ->n …
3y ago
Japt, 15 14 bytes @§XnÈ …
3y ago
C (gcc), 126 129 bytes ```c …
4y ago
[JavaScript (Node.js)], 81 byt …
4y ago
[JavaScript (Node.js)], 86 byt …
4y ago
1 comment thread