Post History
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&...
Question
code-golf
#4: Post edited
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.
- 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 <a class="badge is-tag">code-golf</a>, so shortest code wins.
#1: Initial revision
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.