Post Reply 
Mini-challenge: MAX(factors of 2 or 5)
01-20-2018, 10:09 AM (This post was last modified: 01-20-2018 10:10 AM by pier4r.)
Post: #21
RE: Mini-challenge: MAX(factors of 2 or 5)
(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.

Wikis are great, Contribute :)
Find all posts by this user
Quote this message in a reply
01-21-2018, 11:45 AM
Post: #22
RE: Mini-challenge: MAX(factors of 2 or 5)
There is a version of max factors 2 and 5 here for the Prime:
http://www.hpmuseum.org/forum/thread-9986.html

Stephen Lewkowicz (G1CMZ)
https://my.numworks.com/python/steveg1cmz
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)