Mini-challenge: MAX(factors of 2 or 5)
|
01-16-2018, 10:52 PM
Post: #1
|
|||
|
|||
Mini-challenge: MAX(factors of 2 or 5)
This mini-challenge is really is a cry for help improving a painfully inelegant-looking routine.
Suppose an integer X contains prime factors of 2^Y and 5^Z. What is MAX(Y,Z)? Example: 2000 = 2^4 * 5^3, so Y=4 and Z=3, so MAX(Y,Z)=4. The following ugly HP 50g routine takes X as its input and outputs MAX(Y,Z): Code: << FACTORS DUPDUP Input: 31250 (which = 2*5^6) Output: 6 in 0.114 seconds Input: 2^555 Output: 555 in 0.97 seconds Input: 3^175 Output: 0 in 0.87 seconds It works and it's fast enough, but it looks like a brutally hamfisted approach. It hurts my eyes. There MUST be a simple and elegant way of doing this. Thanks for any insights you can share! <0|ΙΈ|0> -Joe- |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 3 Guest(s)