Skip to main content

Timeline for Is this number a prime?

Current License: CC BY-SA 3.0

25 events
when toggle format what by license comment
Sep 21, 2015 at 15:14 comment added J Atkin Wow, this is almost the exact same code I wrote :) You can save a char by using > instead of !=.
Sep 12, 2015 at 3:00 history edited rayryeng CC BY-SA 3.0
added 241 characters in body
Sep 12, 2015 at 2:58 comment added rayryeng @kirbyfan64sos - Wicked. Thanks so much! BTW, I +1ed your O attempt. Nice and sweet!
Sep 12, 2015 at 2:57 comment added kirbyfan64sos @rayryeng Yeah, I didn't know about it either until around a month ago! Apparently, any time a keyword immediately follows a number, you can leave out the space.
Sep 12, 2015 at 2:56 comment added rayryeng @kirbyfan64sos - really? Wow I never knew that about the or. Thanks for the tips again! BTW, I went with your second attempt. The first attempt that I did to change the and to or is wrong.
Sep 12, 2015 at 2:35 comment added kirbyfan64sos @rayryeng One more change: you can shave 2 or 3 bytes by dropping the parentheses for the print call and removing the space before the or thanks to Python's weird parser: n=input();print n==1or all(n%i for in range(2,n)).
Sep 12, 2015 at 1:54 history edited rayryeng CC BY-SA 3.0
added 186 characters in body
Sep 12, 2015 at 1:46 comment added rayryeng @kirbyfan64sos - OK, made it a full program. Went up to 52 bytes. Thanks for the tips!
Sep 12, 2015 at 1:45 history undeleted rayryeng
Sep 12, 2015 at 1:43 history deleted rayryeng via Vote
Sep 12, 2015 at 1:42 history edited rayryeng CC BY-SA 3.0
added 1130 characters in body
Sep 12, 2015 at 1:27 comment added kirbyfan64sos Try def f(n):print n!=1 and all(n%i for i in range(2,n)). It needs to be a complete program, though.
Sep 12, 2015 at 1:25 comment added rayryeng @kirbyfan64sos - Nope. Same problem as before. Returns True for n==1 and False otherwise.
Sep 12, 2015 at 1:24 comment added rayryeng @kirbyfan64sos - Let me experiment. Thanks for the tips.
Sep 12, 2015 at 1:24 comment added kirbyfan64sos I think you can reduce this to def f(n):print(n==1 and all(n%i for i in range(2,n))) (but I haven't tested it).
Sep 12, 2015 at 1:19 history edited rayryeng CC BY-SA 3.0
deleted 4 characters in body
Sep 12, 2015 at 1:12 comment added rayryeng @feersum - Now officially fixed. Thanks.
Sep 12, 2015 at 1:12 comment added rayryeng @Mauris - Fixed now. Thanks.
Sep 12, 2015 at 1:12 history edited rayryeng CC BY-SA 3.0
added 277 characters in body
Sep 12, 2015 at 1:07 history rollback rayryeng
Rollback to Revision 1
Sep 12, 2015 at 1:07 comment added rayryeng @Mauris - Oops. I didn't fix that properly lol. Was on mobile. I'm on my computer now. Fixing.
Sep 12, 2015 at 1:05 comment added lynn You made it return False for every possible input but 1, which should be False :)
Sep 12, 2015 at 0:48 history edited rayryeng CC BY-SA 3.0
edited body
Sep 12, 2015 at 0:40 comment added feersum It has to return false for 1.
Sep 11, 2015 at 23:01 history answered rayryeng CC BY-SA 3.0