Maths/Stats challenge - 1 of 2 - polls
|
05-24-2022, 01:35 PM
(This post was last modified: 05-25-2022 04:59 PM by Albert Chan.)
Post: #7
|
|||
|
|||
RE: Maths/Stats challenge - 1 of 2 - polls
(05-24-2022 10:21 AM)Joe Horn Wrote: Aha! I understand now. Unfortunately, it is possible solutions not from the convergents (even semi-convergents) With small search range (<100), brute force (for "roundtrip") may be the simplest solution. Code: function badn(n,P) Note: round(), does half-way-away-from-zero. For half-way-to-even, use rint() instead. lua> P = {16,2,51,31} -- one of EdS2's example lua> n = ceil(100/(16-2+1)) -- = ceil(100/15) = 7 lua> while badn(n,P) do n=n+1 end lua> n -- smallest solution 45 Had we do convergents/semi-convergents of, say, 31%, we get this: Code: 31% 0 3 4 2 3 Checked convergents/semi-convergents denominator (<100): 13, 29, 42, 71, none will work. We would have missed all these: lua> for n=45,99 do : if not badn(n,P) then io.write(n,' ') end : end 45 49 51 55 61 81 83 85 86 87 88 89 90 91 93 94 95 96 97 98 99 |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)