Timeline for Is this number a factorial?
Current License: CC BY-SA 3.0
9 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Jun 17, 2020 at 9:04 | history | edited | Community Bot |
Commonmark migration
|
|
| May 23, 2017 at 14:01 | comment | added | sudee | Check out Laikoni's answer for division based approach. | |
| May 23, 2017 at 2:48 | comment | added | Jon Purdy |
Nice and simple. I thought I could do better with division—say, divMod by [1..] successively until reaching a zero remainder with a quotient of 1 (factorial) or a nonzero remainder (non-factorial), but it doesn’t seem to be the right approach. I did find this cute 46-character solution, though: f|let x%n=mod n x==0&&(x+1)%div n x||n==1=(1%).
|
|
| May 20, 2017 at 16:24 | comment | added | sudee | I meant something along the lines of "the solution should terminate within a reasonable timeframe", but I guess it fits the requirements either way. Thanks! | |
| May 20, 2017 at 16:20 | history | edited | sudee | CC BY-SA 3.0 |
added 79 characters in body
|
| May 20, 2017 at 12:44 | comment | added | Laikoni |
None that I am aware of. code-golf asks for a solution in as few bytes as possible without any efficiency statements. Also on my machine the function works up to 40430 without noticeable delay.
|
|
| May 20, 2017 at 12:15 | comment | added | sudee | Isn't there some rule about code efficiency? | |
| May 20, 2017 at 11:17 | comment | added | Laikoni |
f n=elem n$scanl1(*)[1..n] is ridiculous inefficient but shorter.
|
|
| May 20, 2017 at 10:04 | history | answered | sudee | CC BY-SA 3.0 |