• Prog Challenge

    From Nuxxie@21:1/5 to All on Thu Mar 7 18:11:17 2024
    Programming is about mathematics and not coding.

    Problem:

    Any rational number a/b (in lowest terms) can be expressed either
    as a terminating decimal or a repeating decimal.

    We consider here only repeating decimals.

    Given, a and b, which are intergers with any number of digits,
    find the repeating portion in the decimal expansion.

    That is, the decimal expansion will be:

    a1, a2, a3, ... an, [r1, r2, r3 ... rn]

    where [... ri ...] is the repeating portion.

    Example:

    1/28 = 0.03 571428 571428...

    The non-repeating, leading portion can be very long and so too can
    the repeating portion.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Nuxxie@21:1/5 to Nuxxie on Fri Mar 8 14:54:29 2024
    On Fri, 08 Mar 2024 14:20:12 +0000, Nuxxie wrote:


    But it fails for 1/28:

    zn_order(10,28);
    false


    I found out the problem here.

    The denominator, d, has to be factored as 2^i * 5^j * d', where
    possibly i=1 and j=1.

    In this case, 28 = 2^2 * 7 (i.e. i=2, j=0)

    Now, zn_order(10,7) = 6

    Thus 1/28 has a repeating portion of length 6 which is preceeded
    by max(i,j) = 2 digits:

    1/28 = 0.03571428571428...

    This is fantastic stuff!

    My main source, so far, is this link:

    https://math.stackexchange.com/questions/377683/length-of-period-of- decimal-expansion-of-a-fraction

    Maxima uses multi-precision, based on GMP, and can handle extremely
    large decimal expansions.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Nuxxie@21:1/5 to Physfitfreak on Fri Mar 8 14:20:12 2024
    On Thu, 07 Mar 2024 21:25:16 -0600, Physfitfreak wrote:


    I don't think the dorks here know such stuff. And the good ones believe
    it's waste of time but what they do (i.e. "fart") is not waste of time.


    Project Euler, a well respected forum for programmers, doesn't think
    that it's a waste of time:

    https://projecteuler.net/problem=26



    So I'll go ahead and ruin it for them all :)

    (method of nines)


    I don't know. Being a scientist/engineer, I have little background
    in number theory.

    But, after some research, it is related to the "multiplicative order"
    of the denominator.

    In Maxima CAS, there is a function that determines the multiplicative
    order: zn_order(a, d), where a is the base and d the denominator.

    Example:

    zn_order(10,31);
    15

    Thus, 1/31 should have a repeating length of 15, and it does.

    zn_order(10,79832137);
    516846

    1/79832137 should have a repeating length of 516846; I haven't checked.

    But it fails for 1/28:

    zn_order(10,28);
    false

    So the method is not totally general.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Nuxxie@21:1/5 to Nuxxie on Fri Mar 8 16:04:55 2024
    On Fri, 08 Mar 2024 15:43:54 +0000, Nuxxie wrote:


    1/37252902384619140625


    The decimal expansion will begin with 11 digits followed by a repeating porion of length 54,494,498,496.

    This number would need 64 GiB of memory, but we could write it out to a
    file using Maxima or bc or GMP.


    Someone please write out this number to a file. As 1 byte per character
    it should be about 55 GiB in size.

    Then verify that the decimals start with 11 digits and then repeat
    after 54,494,498,496 + 11 digits. Just verify that the first 100 or
    so digits are the same.

    Y'all have big, fat mouths. Let's see if that can translate into
    serious computing action.

    The first to do it will receive a BIG PRIZE.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Nuxxie@21:1/5 to Nuxxie on Fri Mar 8 15:43:54 2024
    On Fri, 08 Mar 2024 14:54:29 +0000, Nuxxie wrote:


    1/28 = 0.03571428571428...

    This is fantastic stuff!


    Let's now do a big one.

    1/37252902384619140625

    First find the prime factorization:

    ifactors(37252902384619140625);
    [[5,11],[7,1],[47297,1],[2304403,1]]

    Thus, we need to express this as:

    5^11 * 762939440837

    Now find the multiplicative order:

    zn_order(10, 762939440837);

    54494498496

    The result:

    The decimal expansion will begin with 11 digits followed
    by a repeating porion of length 54,494,498,496.

    This number would need 64 GiB of memory, but we could
    write it out to a file using Maxima or bc or GMP.

    I won't try but maybe someone else will.

    This kind of stuff is what a computer is for. No fucking Netflix.
    No fucking Gmail. Just this.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From DFS@21:1/5 to rbowman on Fri Mar 8 15:12:18 2024
    On 3/8/2024 2:56 PM, rbowman wrote:
    On Thu, 7 Mar 2024 21:25:16 -0600, Physfitfreak wrote:

    (method of nines)

    Ah, nines. When I was in elementary school I got pretty good with the Trachtenberg system. I would check the answer by casting out the nines.

    https://en.wikipedia.org/wiki/Trachtenberg_system https://en.wikipedia.org/wiki/Casting_out_nines

    That really pissed off my teachers. "Show your work!"


    elementary school? wtf?

    I figured you were some kind of Young Sheldon-ish savant.

    I got very close to perfect scores in high school geometry. It's all
    downhill since.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From rbowman@21:1/5 to Physfitfreak on Fri Mar 8 19:56:56 2024
    On Thu, 7 Mar 2024 21:25:16 -0600, Physfitfreak wrote:

    (method of nines)

    Ah, nines. When I was in elementary school I got pretty good with the Trachtenberg system. I would check the answer by casting out the nines.

    https://en.wikipedia.org/wiki/Trachtenberg_system https://en.wikipedia.org/wiki/Casting_out_nines

    That really pissed off my teachers. "Show your work!"

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From DFS@21:1/5 to Physfitfreak on Fri Mar 8 15:35:56 2024
    On 3/7/2024 10:25 PM, Physfitfreak wrote:
    On 3/7/2024 12:11 PM, Nuxxie wrote:
    Programming is about mathematics and not coding.

    Problem:

    Any rational number a/b (in lowest terms) can be expressed either
    as a terminating decimal or a repeating decimal.

    We consider here only repeating decimals.

    Given, a and b, which are intergers with any number of digits,
    find the repeating portion in the decimal expansion.

    That is, the decimal expansion will be:

    a1, a2, a3, ... an, [r1, r2, r3 ... rn]

    where [... ri ...] is the repeating portion.

    Example:

    1/28 = 0.03 571428 571428...

    The non-repeating, leading portion can be very long and so too can
    the repeating portion.



    I don't think the dorks here know such stuff. And the good ones believe
    it's waste of time but what they do (i.e. "fart") is not waste of time.

    So I'll go ahead and ruin it for them all :)

    (method of nines)



    Ruin away, Sandy. You 2 neurotics are the only ones who care about such nonsense anyway.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From DFS@21:1/5 to Lameass Larry Piet on Fri Mar 8 20:53:59 2024
    On 3/8/2024 9:20 AM, Lameass Larry Piet wrote:
    On Thu, 07 Mar 2024 21:25:16 -0600, Physfitfreak wrote:


    I don't think the dorks here know such stuff. And the good ones believe
    it's waste of time but what they do (i.e. "fart") is not waste of time.


    Project Euler, a well respected forum for programmers, doesn't think
    that it's a waste of time:

    https://projecteuler.net/problem=26



    Remember when you said the exact opposite?


    "That entire "Project Euler" web site is pure baloney." Feeb July 2021


    "What a totally lame project [Project Euler]. It's where all the string manipulators congregate." Feeb July 2021


    phony twat.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From rbowman@21:1/5 to Physfitfreak on Sat Mar 9 02:12:33 2024
    On Fri, 8 Mar 2024 15:16:29 -0600, Physfitfreak wrote:

    At one of my jobs, a printing clerk astonished me with calculating large multiplications in his mind, very fast. I kept asking him how he did it,
    and he always only smiled at me Every time we were bored we would begin
    a race getting the result of some multiplication in mind. Every single
    time he won of course. It was fun.

    I used to be good at it but it's a definite use it or lose it skill.

    I'm a Yankee by birth and even had a great something grandfather that
    fought in that war under Miles but I think it was a raw deal. Leaving the
    whole slavery red herring aside I am not comfortable with the Roach Motel theory of government.

    https://www.youtube.com/watch?v=jKhGHxO-woc

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From rbowman@21:1/5 to DFS on Sat Mar 9 02:01:17 2024
    On Fri, 8 Mar 2024 15:12:18 -0500, DFS wrote:

    I got very close to perfect scores in high school geometry. It's all downhill since.

    I never got into that QED stuff. Being a code monkey I'll take some old
    Greek's word for it an cut to the chase.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From DFS@21:1/5 to Larry 'Nuxxie' Piet on Fri May 3 15:43:56 2024
    On 3/8/2024 10:43 AM, Larry 'Nuxxie' Piet wrote:

    The result:

    The decimal expansion will begin with 11 digits followed
    by a repeating porion of length 54,494,498,496.

    This number would need 64 GiB of memory, but we could
    write it out to a file using Maxima or bc or GMP.

    I won't try but maybe someone else will.

    This kind of stuff is what a computer is for. No fucking Netflix.
    No fucking Gmail. Just this.


    no gmail? idiot.

    no online sports or videos? idiot.

    Screw that useless, boring math twaddle. The popular trend today is
    Usenet databases:

    =======================================================================================
    Validity Check Articles =======================================================================================
    Body 1000
    Charset 1000
    Content-Transfer-Encoding 888
    Content-Type 1000
    Date 1000
    From 1000
    Message-ID 1000
    References 1000
    Subject 1000
    User-Agent 1000

    New Threads 30
    Replies 970


    ======================================================
    Posting Recap
    ======================================================
    Articles: 2690968-2692089
    1000 posts were made
    Start: 2024-05-03 13:02:28
    End : 2024-05-03 13:02:35
    6s to process 1000 posts (151 per sec) ======================================================

    151 per second? Praise be to Joel!

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)