Skip to content
Ta180m  /   Idiot-Code-Golf  /   Discussions #7  /  
  • Unwatch 1

    Notifications

    Get push notifications on iOS or Android.
  • Fork 0

Problem 6: Find the Prime #7

Unanswered
Ta180m asked this question in Q&A
Problem 6: Find the Prime #7
on Apr 18, 2021 · 3 answers · 2 replies

Did you know that between any positive number n and 2n inclusive, there is at least one prime number?

Given a number n, find a prime between n and 2n!

Replies

3 suggested answers
·
2 replies

Question out of curiosity: how has this been proven If we can't see a pattern in primes?

2 replies
@Ta180m

Ta180m on Apr 19, 2021
Maintainer Author

This theorem, called Bertrand's Postulate, actually has a "short and elegant" proof. (I guess it's "short and elegant" compared to something like Fermat's Last Theorem which is over 100 pages long)

@mpldr

I won't act as if I understand that. But I accept this as "someone smarter said so and other smarter guys did not find an error".

@Ta180m

Ta180m
on Apr 19, 2021
Maintainer Author

When your screen is only wide enough to fit 14 characters: A multi-line one-liner!

n=int(input())
print([i for i
in range(n,2*n
) if all(not i
%j==0 for j in
range(2, i))])
0 replies
@Ta180m

Pull the repo and try next-prime/next.html … it will tell you the next prime… kinda.

Imagine some blinking banners on the page as well… I couldn't be bothered to make them yet. Maybe later.

0 replies
@Ta180m
Select a reply ctrl .
Remember, contributions to this repository should follow our GitHub Community Guidelines.
Category
Change category
Q&A
Labels
None yet
2 participants
  • Lock conversation

    Lock conversation on this discussion

    • Other users can’t add new comments to this discussion.
    • You and other collaborators with access to this repository can still leave comments that others can see.
    • You can always unlock this discussion again in the future.
  • Transfer discussion
  • Pin discussion

    Configure pinned discussion

    Up to 4 discussions can be pinned and they will appear publicly at the top of the discussions page.

  • Create issue from discussion
  • Delete discussion?

    The discussion will be deleted permanently. You will not be able to restore the discussion or its comments

Loading complete