HP Forums
Mini-challenge: MAX(factors of 2 or 5) - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: General Forum (/forum-4.html)
+--- Thread: Mini-challenge: MAX(factors of 2 or 5) (/thread-9955.html)

Pages: 1 2


RE: Mini-challenge: MAX(factors of 2 or 5) - pier4r - 01-20-2018 10:09 AM

(01-20-2018 04:21 AM)Joe Horn Wrote:  Please be aware that MAX(factors of 2 or 5) is actually needed for an actual programming task, namely, printing integer ratios as repeating decimals. MAX(denominator's factors of 2 or 5) yields the number of digits after the decimal point which do NOT repeat. So this isn't just a fizzbuzz problem... unless you mean something else by "a fizzbuzz problem" in which case please elucidate.

Surely your MAX function is a bit more complicated (and thanks to connect it to the bigger problem, it makes the discussion more interesting).

Nonetheless the fizzbuzz problem is very simple but it has the core problem there. Find out if a number is divisible by 3, 5 or both. Now if you extend it saying "find out how many times a number is divisible by 3 or 5 " mostly you have the core task of your max function, just with the "max" left out.

Now going back to the max(factors(L)) (because we can extend it, slowly, to an arbitrary list of factors, right? Although 2 and 5 are indeed interesting due to 2*5 = 10) . Has anyone tried with division with increasing power? (that may still not win FACTORS on the 50g though).

Also I found the code of claudio pretty neat, once again hiding the many subtraction behind GCD.


RE: Mini-challenge: MAX(factors of 2 or 5) - StephenG1CMZ - 01-21-2018 11:45 AM

There is a version of max factors 2 and 5 here for the Prime:
http://www.hpmuseum.org/forum/thread-9986.html