(50g) OEIS A028842: Product of Digits is a Prime
|
09-05-2017, 09:21 PM
(This post was last modified: 09-06-2017 04:50 AM by Joe Horn.)
Post: #2
|
|||
|
|||
RE: (50g) OEIS A028842: Product of Digits is a Prime Sequence
(09-05-2017 02:43 PM)Gerald H Wrote: I am particularly unhappy with this For input X, it returns two numbers A and B. An algorithm that generates A from X is this: 2. / √ 0 RND 4 * Its accuracy is limited by its use of real square roots. Rewriting it for integer accuracy, and generating B from X and A, are left as exercises for the student. EDIT: I wrote that because I was having a devil of a time figuring out how to do it! It finally dawned on me after staring at the numbers long enough. Here's a routine that inputs X and outputs X, A, B: Code: DUP 2. / √ DUP 0. RND 4. * SWAP .5 + FP OVER * CEIL The bigger the input, the larger the speed difference. For an input of 1E7, the loop takes 11 seconds, and the direct approach takes 0.022 seconds, 500 times faster. EDIT 2: Due to roundoff errors, this routine gets incorrect results for large inputs. Don't trust the output for inputs > 1E11. It seems to be ok for anything smaller than that. <0|ɸ|0> -Joe- |
|||
« Next Oldest | Next Newest »
|
Messages In This Thread |
(50g) OEIS A028842: Product of Digits is a Prime - Gerald H - 09-05-2017, 02:43 PM
RE: (50g) OEIS A028842: Product of Digits is a Prime Sequence - Joe Horn - 09-05-2017 09:21 PM
RE: (50g) OEIS A028842: Product of Digits is a Prime Sequence - Gerald H - 09-06-2017, 05:43 AM
RE: (50g) OEIS A028842: Product of Digits is a Prime Sequence - Joe Horn - 09-06-2017, 06:27 AM
RE: (50g) OEIS A028842: Product of Digits is a Prime Sequence - Gerald H - 09-06-2017, 11:57 AM
RE: (50g) OEIS A028842: Product of Digits is a Prime Sequence - Gerald H - 09-06-2017, 03:44 PM
RE: (50g) OEIS A028842: Product of Digits is a Prime Sequence - Gerald H - 09-06-2017, 06:43 PM
RE: (50g) OEIS A028842: Product of Digits is a Prime Sequence - Gerald H - 09-07-2017, 10:00 AM
RE: (50g) OEIS A028842: Product of Digits is a Prime Sequence - pier4r - 09-07-2017, 12:08 PM
RE: (50g) OEIS A028842: Product of Digits is a Prime Sequence - Gerald H - 09-07-2017, 12:14 PM
|
User(s) browsing this thread: 4 Guest(s)