Timeline for answer to Is this number a prime? by uno20001
Current License: CC BY-SA 3.0
Post Revisions
18 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Jan 16, 2025 at 21:01 | review | Suggested edits | |||
| Jan 16, 2025 at 23:46 | |||||
| Oct 27, 2020 at 17:35 | comment | added | Mathieu CAROFF | replace n%i==0 by n%i<1 | |
| Aug 7, 2020 at 21:53 | comment | added | SwimBikeRun | Ah I see, I figured this out after reading the original post more closely. Thanks! | |
| Aug 7, 2020 at 16:43 | comment | added | The Matt | @SwimBikeRun, you're correct. Mine is only an improvement on John Lyon though it doesn't meet requirements for n < 2. Sorry for the confusion. | |
| Aug 4, 2020 at 0:35 | comment | added | SwimBikeRun | @TheMatt - Doesn't work for 1 though. 1 isn't prime but this says it is. | |
| Feb 7, 2020 at 22:39 | comment | added | The Matt |
50 chars, n=int(input());print(all(n%m for m in range(2,n)))
|
|
| Jan 14, 2019 at 22:07 | comment | added | MilkyWay90 | If you used Python 2, you could change int(input()) to input() because of Python 2's eval. However, using a lambda would be even shorter | |
| Sep 20, 2017 at 17:17 | comment | added | 0WJYxW9FMN |
Outgolfed! Mine uses a completely different method. Rather than n%i==0, though, you could have n%i<1 because stuff using mod is never negative. That would save a byte.
|
|
| Oct 17, 2016 at 15:52 | comment | added | Erik the Outgolfer |
Use n%i<1 instead.
|
|
| Mar 20, 2016 at 4:15 | comment | added | CalculatorFeline | Are you serious. Spend 25 extra characters for a lame quadratic speedup? Here we hate bytes. We spend every hour,minute, and second of our lives getting rid of the nineteenth byte. (Just kidding. But we don't do time optimizations that increase program length.) | |
| Sep 17, 2015 at 16:21 | comment | added | yask |
for i in range(2,math.sqrt(n)+1)
|
|
| Sep 16, 2015 at 5:38 | comment | added | John Lyon |
52 bytes: n=m=int(input()), print(all(n%m for m in range(2,n)))
|
|
| Sep 12, 2015 at 7:46 | history | edited | Beta Decay | CC BY-SA 3.0 |
The name of the language, by the design of the challenge, is quite important
|
| Sep 11, 2015 at 17:14 | history | edited | uno20001 | CC BY-SA 3.0 |
use input()
|
| Sep 11, 2015 at 17:11 | comment | added | uno20001 | Thanks, I've already written with using of input(), but I forgot to refresh my answer. Thanks again! | |
| Sep 11, 2015 at 17:02 | comment | added | Beta Decay |
Take input using input() would be much shorter
|
|
| Sep 11, 2015 at 16:34 | review | Low quality posts | |||
| Sep 11, 2015 at 16:54 | |||||
| Sep 11, 2015 at 16:16 | history | answered | uno20001 | CC BY-SA 3.0 |