|
|
|
|
#58 by N. J. A. Sloane at Sun Feb 19 16:20:06 EST 2023
|
|
|
|
#57 by N. J. A. Sloane at Sun Feb 19 16:20:04 EST 2023
|
| LINKS
|
<a href="/index/Mo#MWP">Index entries for sequences related to Most Wanted Primes video</a>
|
| STATUS
|
approved
editing
|
|
|
|
#56 by N. J. A. Sloane at Thu Feb 16 23:51:36 EST 2023
|
|
|
|
#55 by N. J. A. Sloane at Thu Feb 16 23:51:34 EST 2023
|
| CROSSREFS
|
Primes when read as if in base 10: A036954.
|
| STATUS
|
approved
editing
|
|
|
|
#54 by N. J. A. Sloane at Thu Feb 16 23:50:09 EST 2023
|
|
|
|
#53 by M. F. Hasler at Wed Feb 15 19:39:01 EST 2023
|
|
|
Discussion
|
Thu Feb 16
| 14:56
| Andrew Howroyd: Some of the PARI programmers (most notably Michael Somos) almost always write a(n) as a total function returning 0 outside the domain. Not everyone may agree with this practice but it is not uncommon. Other peoples programs always looks somewhat alien / questionable and this isn't is a code base where we have rigidly defined standards. [I for example, might not like your habit of defining a function in the middle of a method call to apply, and there is probably stuff you don't like about what I do - that's life living under one roof]. I think we have to distinguish between ok programs and the outrageously awful. Given that this is a one-liner and Charles has added a better program - this would be in the ok category for me.
|
| 15:05
| Andrew Howroyd: This is of course the reason Sean Irvine does everything on github - a place where he can set the rules!!
|
| 19:32
| Kevin Ryde: First pari code is ok. It has to be correct on integers in the sequence domain. Everything else is unspecified. No it shouldn't have been recursive. But it pre-dates the existence of "digits()", so can't blame for not that.
|
| 20:33
| Kevin Ryde: Or rather when I say ok, I mean distinctly ordinary though not wrong. Definitely shouldn't be recursive that way.
|
| 22:23
| M. F. Hasler: Yes, recording with div/mod, not -1. Concerning functions that silently return 0 for arguments outside the domain, this is actively harmful as Charles explains and I agree.
|
|
|
|
#52 by M. F. Hasler at Wed Feb 15 19:36:39 EST 2023
|
| FORMULA
|
a(n) = 10*a(floor(n/3)) + (n mod 3) if n > 0, a(0) = 0. - M. F. Hasler, Feb 15 2023
|
|
|
|
#51 by M. F. Hasler at Wed Feb 15 19:22:29 EST 2023
|
|
|
Discussion
|
Wed Feb 15
| 19:30
| M. F. Hasler: first PARI code is sus...(Not only that in general, "if(n<1,...)" is wrong. [a(-1) is either undefined or 1 but definitely *not* 0 as the function erroneously returns. This is "actively harmul" as explained by Charles on his wiki page on programs.] It looks as if an effort was made to make the function as inefficient as possible... OK, I understand that it serves to illustrate the equally inefficient FORMULA from 2002.)
|
|
|
|
#50 by M. F. Hasler at Wed Feb 15 19:21:52 EST 2023
|
| PROG
|
(Python)
def A007089(n):
n, s = divmod(n, 3); t = 1
while n: n, r = divmod(n, 3); t *= 10; s += r*t
return s # M. F. Hasler, Feb 15 2023
|
| STATUS
|
approved
editing
|
|
|
|
#49 by Peter Luschny at Tue Aug 04 23:44:51 EDT 2020
|
|
|
|