Mini-challenge: MAX(factors of 2 or 5)
|
01-17-2018, 04:49 AM
Post: #4
|
|||
|
|||
RE: Mini-challenge: MAX(factors of 2 or 5)
My implementation of Claudio's approach:
Code: << 0 UNROT This takes a number N in level 2 and a factor F in level 1, and returns the number M of times that F divides N in level 1, and N / F^M in level 2, and... Code: << 10 NDIVS SWAP DUP 2 NDIVS ...takes a number in level 1 and returns the desired result in level 1. I'm a bit conflicted about this challenge because what's mathematically elegant and what's RPL-ically elegant are probably quite different. Claudio's approach is mathematically much better than using the FACTORS function -- why find the complete prime factorization when all you want is the multiplicity of two specific factors? And what about memory usage? Also, the FACTORS approach fails if the factors you're looking at happen not to be primes. |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 6 Guest(s)