The Simplest Math Problem No One Can Solve

HAneo

Well-known member
  • Jan 30, 2007
    12,970
    29,167
    113
    Homagama
    හුකානේ. නිදාගන්න යනකොට ඔටෝ සජෙස්ට් උන නිසා බැලුවේ. මෙන්න බාන්ඩේ . මේ කියන කතාව නම් හරි
    මම නම්බර්ස් ලක්ෂයක් දාල බැලුව ඔක්කොම ඉවර වෙන්නේ මේකේ කියන පැටර්න්



    Code:
     for (int i = 0; i < 100001; i++)
    {
       RunCalc(i);
    }
    Code:
           private void RunCalc(int v)
            {
                WriteValue("Starting round with No: " + v.ToString());
                while (v > 1) {
                    if (v % 2 == 0)
                    {
                        //even
                        v = v / 2;
                        WriteValue("Even No: " + v.ToString());
                    }
                    else {
                        //odd
                        v = v * 3 + 1;
                        WriteValue("Odd No: " + v.ToString());
                    }
                }
                WriteValue("End Cal for no:: " + v.ToString());
                WriteValue("");
            }
    Code:
      private void WriteValue(string v)
      {
           Console.WriteLine(v + Environment.NewLine);
       }
    මම නම් ගණන් කාරයෙක් නෙමේ. මේකේ ඉන්න ගණිත කාරයෝ බලපල්ලකො මේක පොඩ්ඩක් රෙද්ද
     

    imhotep

    Well-known member
  • Mar 29, 2017
    14,824
    8
    35,333
    113
    The notorious Collatz Conjecture. Proposed in the 1930s by Lothar Collatz, this is also referred to as the "3x+1 Conjecture" or the "Syracuse Problem". It's notorious because it has wasted so much valuable time of many mathematicians.

    About three years ago the quite well known Australian born Terence Tao (Professor of Maths, UCLA) posted a proof showing that — at the very least — the Collatz conjecture is “almost” true for “almost” all numbers. While Tao’s result is not a full proof of the conjecture, it is a major advance on this problem.

    It's also noteworthy to mention John H Conway, one of the most versatile mathematicians of the past century, who made influential contributions to group theory, analysis, topology, number theory, geometry, algebra and combinatorial game theory. (He sadly passed away due to Covid in April 2020.)

    John Conway developed the language FRACTRAN using the Col( ) function. It's "A SIMPLE UNIVERSAL PROGRAMMING LANGUAGE FOR ARITHMETIC" -
    No complicated programming manual, the entire syntax can be learned in 15 secs, quite complicated functions can be written immediately.
    FRACTRAN is Turing complete, meaning any computation that can be performed by a computer can also be computed using a FRACTRAN program subject to some limitations. (In the Turing machine itself)

    PS: Only now, was I able to watch the video. It's a very informative and a complete video. Everything I mentioned above, has been already covered by the presenter including John Conway. 👍
     
    Last edited:

    olu bakka

    Well-known member
  • Aug 18, 2011
    22,008
    22,411
    113
    අම්මටහුඩු මාත් ඕක බලල python code එකක් ගැහුව

    මේ වගේ output එකක් ගන්න පුලුවන්

    Code:
    Enter from number: 5
    Enter to number: 10
    +------+------------+-------+
    | Seed | Max Number | Steps |
    +------+------------+-------+
    |  5   |     16     |   5   |
    |  6   |     16     |   8   |
    |  7   |     52     |  16   |
    |  8   |     8      |   3   |
    |  9   |     52     |  19   |
    |  10  |     16     |   6   |
    +------+------------+-------+
    Maximum number reached in the sequence = 52 (Seed number = [7, 9])
    Maxiumum steps = 19 (Seed number = [9])

    Python:
    # Collatz Conjucture
    # Info - https://www.youtube.com/watch?v=094y1Z2wpJg&ab_channel=Veritasium
    from tabulate import tabulate
    
    def calculation (n1, n2):
        i = 0
        nlist = []
        for x in range(n1, n2+1):
            maxn = 0
            s = 0
            nlist.append([])
            nlist[i].append(x)
            if x % 10000 == 0:
                print(round(((x - n1) / (n2 - n1)) * 100, 2), "%")
            while True:
                #print(int(x), end=" , ")
                if x > maxn:
                    maxn = x
    
                if x == 1:
                    break
                else:
                    s += 1
                    if x % 2 == 1:
                        x = (3*x) + 1
                    else:
                        x = x//2
            nlist[i].append(maxn)
            nlist[i].append(s)
            i += 1
    
        seqmaxn = 0
        maxnseed = []
        seqmaxs = 0
        maxsseed = []
        for q in nlist:
            if q[0] % 10000 == 0:
                print(round(50 + (((q[0] - n1) / (n2 - n1)) * 50), 2), "%")
            if q[1] == seqmaxn:
                maxnseed.append(q[0])
            elif q[1] > seqmaxn:
                seqmaxn = q[1]
                maxnseed.clear()
                maxnseed.append(q[0])
    
            if q[2] == seqmaxs:
                maxsseed.append(q[0])
            elif q[2] > seqmaxs:
                seqmaxs = q[2]
                maxsseed.clear()
                maxsseed.append(q[0])
        print(tabulate(nlist, headers=["Seed", "Max Number", "Steps"], tablefmt="pretty"))
        print(f"Maximum number reached in the sequence = {seqmaxn} (Seed number = {maxnseed})\nMaxiumum steps = {seqmaxs} (Seed number = {maxsseed})\n")
    
    
    while True:
        num1 = int(input("Enter from number: "))
        num2 = int(input("Enter to number: "))
    
        calculation(num1, num2)

    PS: කෝඩින් වල professional practices දන්නෙ නෑ යන්තන් අතපත ගානව විතරයි. ඒක හින්ද සමාවෙන්න ඕනෙ ගොන් පාට් තිබ්බොත්
     
    Last edited:

    kasun090354t

    Well-known member
  • Aug 21, 2011
    24,054
    36,053
    113
    කෑගල්ල
    අම්මටහුඩු මාත් ඕක බලල python code එකක් ගැහුව

    මේ වගේ output එකක් ගන්න පුලුවන්

    Code:
    Enter from number: 5
    Enter to number: 10
    +------+------------+-------+
    | Seed | Max Number | Steps |
    +------+------------+-------+
    |  5   |     16     |   5   |
    |  6   |     16     |   8   |
    |  7   |     52     |  16   |
    |  8   |     8      |   3   |
    |  9   |     52     |  19   |
    |  10  |     16     |   6   |
    +------+------------+-------+
    Maximum number reached in the sequence = 52 (Seed number = [7, 9])
    Maxiumum steps = 19 (Seed number = [9])

    Python:
    # Collatz Conjucture
    # Info - https://www.youtube.com/watch?v=094y1Z2wpJg&ab_channel=Veritasium
    from tabulate import tabulate
    
    def calculation (n1, n2):
        i = 0
        nlist = []
        for x in range(n1, n2+1):
            maxn = 0
            s = 0
            nlist.append([])
            nlist[i].append(x)
            if x % 10000 == 0:
                print(round(((x - n1) / (n2 - n1)) * 100, 2), "%")
            while True:
                #print(int(x), end=" , ")
                if x > maxn:
                    maxn = x
    
                if x == 1:
                    break
                else:
                    s += 1
                    if x % 2 == 1:
                        x = (3*x) + 1
                    else:
                        x = x//2
            nlist[i].append(maxn)
            nlist[i].append(s)
            i += 1
    
        seqmaxn = 0
        maxnseed = []
        seqmaxs = 0
        maxsseed = []
        for q in nlist:
            if q[0] % 10000 == 0:
                print(round(50 + (((q[0] - n1) / (n2 - n1)) * 50), 2), "%")
            if q[1] == seqmaxn:
                maxnseed.append(q[0])
            elif q[1] > seqmaxn:
                seqmaxn = q[1]
                maxnseed.clear()
                maxnseed.append(q[0])
    
            if q[2] == seqmaxs:
                maxsseed.append(q[0])
            elif q[2] > seqmaxs:
                seqmaxs = q[2]
                maxsseed.clear()
                maxsseed.append(q[0])
        print(tabulate(nlist, headers=["Seed", "Max Number", "Steps"], tablefmt="pretty"))
        print(f"Maximum number reached in the sequence = {seqmaxn} (Seed number = {maxnseed})\nMaxiumum steps = {seqmaxs} (Seed number = {maxsseed})\n")
    
    
    while True:
        num1 = int(input("Enter from number: "))
        num2 = int(input("Enter to number: "))
    
        calculation(num1, num2)

    PS: කෝඩින් වල professional practices දන්නෙ නෑ යන්තන් අතපත ගානව විතරයි. ඒක හින්ද සමාවෙන්න ඕනෙ ගොන් පාට් තිබ්බොත්
    මෙහෙම table output එකක් දැකලා තිබ්බා ට. Test කරලා තිබ්බේ නෑ. එල එල code රිකට thanks
     

    HAneo

    Well-known member
  • Jan 30, 2007
    12,970
    29,167
    113
    Homagama
    අම්මටහුඩු මාත් ඕක බලල python code එකක් ගැහුව

    මේ වගේ output එකක් ගන්න පුලුවන්

    Code:
    Enter from number: 5
    Enter to number: 10
    +------+------------+-------+
    | Seed | Max Number | Steps |
    +------+------------+-------+
    |  5   |     16     |   5   |
    |  6   |     16     |   8   |
    |  7   |     52     |  16   |
    |  8   |     8      |   3   |
    |  9   |     52     |  19   |
    |  10  |     16     |   6   |
    +------+------------+-------+
    Maximum number reached in the sequence = 52 (Seed number = [7, 9])
    Maxiumum steps = 19 (Seed number = [9])

    Python:
    # Collatz Conjucture
    # Info - https://www.youtube.com/watch?v=094y1Z2wpJg&ab_channel=Veritasium
    from tabulate import tabulate
    
    def calculation (n1, n2):
        i = 0
        nlist = []
        for x in range(n1, n2+1):
            maxn = 0
            s = 0
            nlist.append([])
            nlist[i].append(x)
            if x % 10000 == 0:
                print(round(((x - n1) / (n2 - n1)) * 100, 2), "%")
            while True:
                #print(int(x), end=" , ")
                if x > maxn:
                    maxn = x
    
                if x == 1:
                    break
                else:
                    s += 1
                    if x % 2 == 1:
                        x = (3*x) + 1
                    else:
                        x = x//2
            nlist[i].append(maxn)
            nlist[i].append(s)
            i += 1
    
        seqmaxn = 0
        maxnseed = []
        seqmaxs = 0
        maxsseed = []
        for q in nlist:
            if q[0] % 10000 == 0:
                print(round(50 + (((q[0] - n1) / (n2 - n1)) * 50), 2), "%")
            if q[1] == seqmaxn:
                maxnseed.append(q[0])
            elif q[1] > seqmaxn:
                seqmaxn = q[1]
                maxnseed.clear()
                maxnseed.append(q[0])
    
            if q[2] == seqmaxs:
                maxsseed.append(q[0])
            elif q[2] > seqmaxs:
                seqmaxs = q[2]
                maxsseed.clear()
                maxsseed.append(q[0])
        print(tabulate(nlist, headers=["Seed", "Max Number", "Steps"], tablefmt="pretty"))
        print(f"Maximum number reached in the sequence = {seqmaxn} (Seed number = {maxnseed})\nMaxiumum steps = {seqmaxs} (Seed number = {maxsseed})\n")
    
    
    while True:
        num1 = int(input("Enter from number: "))
        num2 = int(input("Enter to number: "))
    
        calculation(num1, num2)

    PS: කෝඩින් වල professional practices දන්නෙ නෑ යන්තන් අතපත ගානව විතරයි. ඒක හින්ද සමාවෙන්න ඕනෙ ගොන් පාට් තිබ්බොත්
    අම්මා සුපිරි.
    කොඩින්ග් කියන එක උබ ලියන එක අනික් එකාට තේරුම් ගන්න ලේසි නම් එක තමා හොද බන්
    මේ සිරිලංකාවේ උන් ඕනේ නැති වැඩ දන්නා ගිහින් සමහර වෙලාවට කෝඩ් එක උට තේරෙන්නෙත් නැ වෙන උන්ට තේරෙන්නෙත් නැ
     

    olu bakka

    Well-known member
  • Aug 18, 2011
    22,008
    22,411
    113
    මෙහෙම table output එකක් දැකලා තිබ්බා ට. Test කරලා තිබ්බේ නෑ. එල එල code රිකට thanks
    Tabulate library එකෙන් දැම්මෙ. ඒක install කරල නැත්තන් වැඩ කරන එකක් නෑ.
     
    • Like
    Reactions: NRTG

    olu bakka

    Well-known member
  • Aug 18, 2011
    22,008
    22,411
    113
    අම්මා සුපිරි.
    කොඩින්ග් කියන එක උබ ලියන එක අනික් එකාට තේරුම් ගන්න ලේසි නම් එක තමා හොද බන්
    මේ සිරිලංකාවේ උන් ඕනේ නැති වැඩ දන්නා ගිහින් සමහර වෙලාවට කෝඩ් එක උට තේරෙන්නෙත් නැ වෙන උන්ට තේරෙන්නෙත් නැ
    තව ඉගෙන ගන්න ඕනෙ බන් :D

    මම නම් ගණන් කාරයෙක් නෙමේ. මේකේ ඉන්න ගණිත කාරයෝ බලපල්ලකො මේක පොඩ්ඩක් රෙද්ද
    මේකෙ පට්ටම සිද්දිය දාන දාන නම්බර් එක 1 න් ඉවර වෙන එක නෙමේ. ඒ pattern එකෙන් ගන්න statistical දත්ත real life දේවල් එක්ක සමපාත වෙන එක. අර first digit එකේ frequency එන විදිහ එහෙම මරු. ඒක fraud හොයන්නත් ගන්නව කිවුවෙ. ඇයි එහෙම වෙන්නෙ කියල කවුරුත් දන්නෙ නෑ හැබැයි බඩු වැඩ. මාරයි.
    ------ Post added on Jul 18, 2022 at 11:03 AM
     
    • Haha
    Reactions: Ridunapm

    HAneo

    Well-known member
  • Jan 30, 2007
    12,970
    29,167
    113
    Homagama
    තව ඉගෙන ගන්න ඕනෙ බන් :D


    මේකෙ පට්ටම සිද්දිය දාන දාන නම්බර් එක 1 න් ඉවර වෙන එක නෙමේ. ඒ pattern එකෙන් ගන්න statistical දත්ත real life දේවල් එක්ක සමපාත වෙන එක. අර first digit එකේ frequency එන විදිහ එහෙම මරු. ඒක fraud හොයන්නත් ගන්නව කිවුවෙ. ඇයි එහෙම වෙන්නෙ කියල කවුරුත් දන්නෙ නෑ හැබැයි බඩු වැඩ. මාරයි.
    ------ Post added on Jul 18, 2022 at 11:03 AM
    ඕකට මම මිට වඩා මහන්සි වෙනවා. හැබැයි බන් ඕකට ට්‍රයි කල උන් දැක්කම මම අතෑරියා. මේ මෑත කාලින උන් ට්‍රයි කළා කියන්නේ අපි ට්‍රයි කරන්න යන මෙතඩ් එකමනේ. උන් ඉතින් ලොවෙත් අපිට වඩා ඉස්සරහින් ඉන්න කෙනෙක් වෙන්නම ඕනේ. ඒ නිසා ටයිම් වෙස්ට්. ඒ වෙනුවට ට්‍රයි කරමු ඕනේ නම් එනිග්මා එකට.

     

    olu bakka

    Well-known member
  • Aug 18, 2011
    22,008
    22,411
    113
    ඕකට මම මිට වඩා මහන්සි වෙනවා. හැබැයි බන් ඕකට ට්‍රයි කල උන් දැක්කම මම අතෑරියා. මේ මෑත කාලින උන් ට්‍රයි කළා කියන්නේ අපි ට්‍රයි කරන්න යන මෙතඩ් එකමනේ. උන් ඉතින් ලොවෙත් අපිට වඩා ඉස්සරහින් ඉන්න කෙනෙක් වෙන්නම ඕනේ. ඒ නිසා ටයිම් වෙස්ට්. ඒ වෙනුවට ට්‍රයි කරමු ඕනේ නම් එනිග්මා එකට.


    ඒක් ඇත්ත මචන් ෆන් එකට කරේ.
     
    • Like
    Reactions: NRTG

    imhotep

    Well-known member
  • Mar 29, 2017
    14,824
    8
    35,333
    113
    The Mathematics/Cryptography is clearly explained and there are many easy to understand material available on the Net. Here are two interesting videos.



     
    • Like
    Reactions: TCB Rox and NRTG

    Ridunapm

    Well-known member
  • Jun 22, 2022
    2,005
    2,673
    113
    තව ඉගෙන ගන්න ඕනෙ බන් :D


    මේකෙ පට්ටම සිද්දිය දාන දාන නම්බර් එක 1 න් ඉවර වෙන එක නෙමේ. ඒ pattern එකෙන් ගන්න statistical දත්ත real life දේවල් එක්ක සමපාත වෙන එක. අර first digit එකේ frequency එන විදිහ එහෙම මරු. ඒක fraud හොයන්නත් ගන්නව කිවුවෙ. ඇයි එහෙම වෙන්නෙ කියල කවුරුත් දන්නෙ නෑ හැබැයි බඩු වැඩ. මාරයි.
    ------ Post added on Jul 18, 2022 at 11:03 AM
    ලොල්. ඕක දන් නැත්තෙ මොකාද ඕයි. ඕන ඉලක්කම් සමූහයක 1 තිබීමේ සම්භාවිතාව වැඩියි. 😞

    හුකානේ. නිදාගන්න යනකොට ඔටෝ සජෙස්ට් උන නිසා බැලුවේ. මෙන්න බාන්ඩේ . මේ කියන කතාව නම් හරි
    මම නම්බර්ස් ලක්ෂයක් දාල බැලුව ඔක්කොම ඉවර වෙන්නේ මේකේ කියන පැටර්න්



    Code:
     for (int i = 0; i < 100001; i++)
    {
       RunCalc(i);
    }
    Code:
           private void RunCalc(int v)
            {
                WriteValue("Starting round with No: " + v.ToString());
                while (v > 1) {
                    if (v % 2 == 0)
                    {
                        //even
                        v = v / 2;
                        WriteValue("Even No: " + v.ToString());
                    }
                    else {
                        //odd
                        v = v * 3 + 1;
                        WriteValue("Odd No: " + v.ToString());
                    }
                }
                WriteValue("End Cal for no:: " + v.ToString());
                WriteValue("");
            }
    Code:
      private void WriteValue(string v)
      {
           Console.WriteLine(v + Environment.NewLine);
       }
    මම නම් ගණන් කාරයෙක් නෙමේ. මේකේ ඉන්න ගණිත කාරයෝ බලපල්ලකො මේක පොඩ්ඩක් රෙද්ද

    2^68 ට යනකල් test කරලා තියෙනවා නම් අපිට ඕක ඔය විදිහට හොයන්න resources මදි බං. මට නම් හිතෙන්නෙ තුන් වැනි එක තමයි උත්තරේ. මේක කවදාවත් prove කරන්න බැරි දෙයක්. 👍
    ------ Post added on Jul 18, 2022 at 11:43 AM
     
    • Like
    Reactions: HAneo

    olu bakka

    Well-known member
  • Aug 18, 2011
    22,008
    22,411
    113
    ලොල්. ඕක දන් නැත්තෙ මොකාද ඕයි. ඕන ඉලක්කම් සමූහයක 1 තිබීමේ සම්භාවිතාව වැඩියි. 😞
    සම්භාවිතාව වැඩි වීමයි 30% ක් වීමයි කියන්නෙ දෙකක්නෙ. අනික සම්භාවිතාව වැඩි වීම විතරක් ගත්තත් ඒක great finding එකක්. මොකද හරිනන් 10% ක සමාන සම්භාවිතාවක් තියෙන්න ඕනෙ.

    2^68 ට යනකල් test කරලා තියෙනවා නම් අපිට ඕක ඔය විදිහට හොයන්න resources මදි බං. මට නම් හිතෙන්නෙ තුන් වැනි එක තමයි උත්තරේ. මේක කවදාවත් prove කරන්න බැරි දෙයක්. 👍
    මේවා prove කරන්නෙ theory වලින් මිසක් trial වලින් නෙමේ. trial වලින් වැරදි අවස්තාවක් හොයන් වැරදියි කියල ඔප්පු කරන්න විතරයි.
    ------ Post added on Jul 18, 2022 at 11:53 AM
     

    Ridunapm

    Well-known member
  • Jun 22, 2022
    2,005
    2,673
    113
    සම්භාවිතාව වැඩි වීමයි 30% ක් වීමයි කියන්නෙ දෙකක්නෙ. අනික සම්භාවිතාව වැඩි වීම විතරක් ගත්තත් ඒක great finding එකක්. මොකද හරිනන් 10% ක සමාන සම්භාවිතාවක් තියෙන්න ඕනෙ.


    මේවා prove කරන්නෙ theory වලින් මිසක් trial වලින් නෙමේ. trial වලින් වැරදි අවස්තාවක් හොයන් වැරදියි කියල ඔප්පු කරන්න විතරයි.
    ------ Post added on Jul 18, 2022 at 11:53 AM
    මෝඩ කතානෙ ඉතින්. යකෝ 10% වෙන්නෙ කොහොමද? 10 ගුණාකාරවලින් පැතිරුණ හැම එකකම අනිවාර්යයෙන්ම 1 වැඩිපුර ‍තියෙනවා. ඕක අ‍ැති තරම් prove කරපු සරලම සිද්ධාන්තයක්.

    එ‍්ක නෙවෙයි, උඹලට මේ conjecture එක ලේසියෙන්ම test කරන්න line 19 ක අතිශය සරල python code එකක් හැදුවා. කට්ටියට තේරෙන්න prompt, result ටික සිංහලෙන්මත් දැම්මා. 🤣🤣 අනිත් උන් පුක ඉරාගෙන ඉලක්කම් ගණන් කරන්න කෝඩ් දාලා තියෙනවා. හැබැයි අ‍ැත්තටම එහෙම අ‍ැඟේ පතේ හයියට ගණන් හදන වැල් වටාරම් අවශ්‍ය නැහැ.

    මේකෙ වෙන්නෙ Limit එකක් input අරගෙන, එ‍් දක්වා හැම ඉලක්කමක්ම 4,2,1 loop එකට යනකල් හම්බෙන වැඩිම iterations ගාණ out කරනවා. අපිට ඉලක්කම වැඩක් නැහැ, වැදගත් වෙන්නෙ 1 ට එන්න යන උපරිම steps ගාණ. මේක Divergent නම් ඉලක්කම දාන Limit එකට වඩා යන්න ඕනනෙ. බොහොම සරල සංකල්පයක් තියෙන්නෙ. Resources භාවිතය හරිම අඩුයි. සම්පූර්ණ සංකල්පයම ලේසියෙන් test කරන්නත් පුළුවන්.

    මේක ඕනම තැනක run කරලා, 119 ට එහා limit එකක් දීලා බලහන් දාන ගාණට වඩා වැඩි iterations ගාණක් ගන්න පුළුවන්ද කියලා. කීයටවත් බැහැ. අනික limit වැඩි වෙන්න වෙන්න linear වෙනවා. 1000 දැම්මාම 179, 10,000 දැම්මාම 262, 100,000 දැම්මාම 351, මිලියනයක් දැම්මාම 525. (ඔය කියන්නෙ එ‍් අගය දක්වා ඉලක්කම් ඔක්කොම ගත්තාම 1 වෙන්න අවශ්‍ය උපරිම steps ගාණ ගැන) බලහන් limit එක 10 ගුණයක් ගාණෙ order of magnitude එකකින් වැඩි වෙද්දි පවා iterations වැඩි වෙන්නෙ 50, 100, 150 කින් විතර වගේ. මේ pattern එක දිගටම දකින්න පුළුවන්. ඕක කැඩෙන මැජික් අංකයක් තිබුණොත් දාන limit එකට එහා iterations ගාණක් එන්න එපැයි. එහෙම වෙන කිසිම pattern එකක් නෑ.

    මේක conjecture එකට proof එකක් නෙවෙයි. හැබැයි අර මනුස්සයා අන්තිමට කියන එන්න එන්නම linear වෙන කතාවට හොඳම නිදසුනක්. එක දිගටම ලොකු ගණන් දාලත් iterations ගාණ චූටියි නම් අපිට කොච්චර ලොකු ගාණක් දැම්මත් 1 ට එන්න යන steps ගාණ ඊට වඩා සෑහෙන අඩුයි කියලා ගන්න පුළුවන්. ඉතින් සාධනයක් නොවුණත් මේක ඉතාම හොඳ අපෝහනයක්.

    මේක phone එකකින් වුණත් මිලියන ගාණක් brute force check කරන්න පුළුවන්. යටින් උදාහරණයක් තියෙනවා. 👍

    def testing(Num):
    Iteration=1
    while Num > 1:
    if Num%2 == 1:
    Num = 3*Num+1
    Iteration+=1
    else:
    Num = Num/2
    Iteration+=1
    return(Iteration)
    Highest=0
    X = 1
    while True:
    Limit = int(input("කීය වෙනකල් check කරමුද? :"))
    while X < Limit:
    if testing(X) > Highest:
    Highest = testing(X)
    X+=1
    print(Limit, "දක්වා තියෙන වැඩිම step ගාණ ", Highest,"යි")


    මෙන්න code එක syntax එක්ක සහ run කරාම එන iterations ගාණ. (එළකිරි හුත්තෙ code indentation හරියට එන් නැහැ.) ප්‍රස්තාරයක් අ‍ැන්දා නම් ඕන එකෙක්ට සිද්ධිය තේරෙයි. 👍

    Screenshot_20220718-133455.png
    Screenshot_20220718-133302.png
     
    Last edited:

    kasun090354t

    Well-known member
  • Aug 21, 2011
    24,054
    36,053
    113
    කෑගල්ල
    Tabulate library එකෙන් දැම්මෙ. ඒක install කරල නැත්තන් වැඩ කරන එකක් නෑ.
    ඔව් බාන් vs code එකෙන් ලියන්නේ ඒ මඟුලට library file දාන්න බෑ එක පාර. හෙන ගේමක් දෙන්න ඕනේ location වෙනස් කරලා cmd එකේ.
     

    HAneo

    Well-known member
  • Jan 30, 2007
    12,970
    29,167
    113
    Homagama
    මෝඩ කතානෙ ඉතින්. යකෝ 10% වෙන්නෙ කොහොමද? 10 ගුණාකාරවලින් පැතිරුණ හැම එකකම අනිවාර්යයෙන්ම 1 වැඩිපුර ‍තියෙනවා. ඕක අ‍ැති තරම් prove කරපු සරලම සිද්ධාන්තයක්.

    එ‍්ක නෙවෙයි, උඹලට මේ conjecture එක ලේසියෙන්ම test කරන්න line 19 ක අතිශය සරල python code එකක් හැදුවා. අනිත් උන් පුක ඉරාගෙන ඉලක්කම් ගණන් කරන්න කෝඩ් දාලා තියෙනවා. හැබැයි අ‍ැත්තටම එහෙම අ‍ැඟේ පතේ හයියට ගණන් හදන වැල් වටාරම් අවශ්‍ය නැහැ.

    මේකෙ වෙන්නෙ Limit එකක් input අරගෙන, එ‍් දක්වා හැම ඉලක්කමක්ම 4,2,1 loop එකට යනකල් හම්බෙන වැඩිම iterations ගාණ out කරනවා. අපිට ඉලක්කම වැඩක් නැහැ, වැදගත් වෙන්නෙ 1 ට එන්න යන උපරිම steps ගාණ. මේක Divergent නම් ඉලක්කම දාන Limit එකට වඩා යන්න ඕනනෙ. බොහොම සරල සංකල්පයක් තියෙන්නෙ. Resources භාවිතය හරිම අඩුයි. සම්පූර්ණ සංකල්පයම ලේසියෙන් test කරන්නත් පුළුවන්.

    මේක ඕනම තැනක run කරලා, 119 ට එහා limit එකක් දීලා බලහන් දාන ගාණට වඩා වැඩි iterations ගාණක් ගන්න පුළුවන්ද කියලා. කීයටවත් බැහැ. අනික limit වැඩි වෙන්න වෙන්න linear වෙනවා. 1000 දැම්මාම 179, 10,000 දැම්මාම 262, 100,000 දැම්මාම 351, මිලියනයක් දැම්මාම 525. බලහන් limit එක 10 ගුණයක් ගාණෙ order of magnitude එකකින් වැඩි වෙද්දි පවා iterations වැඩි වෙන්නෙ 50, 100, 150 කින් විතර වගේ. මේ pattern එක දිගටම දකින්න පුළුවන්. ඕක කැඩෙන මැජික් අංකයක් තිබුණොත් දාන limit එකට එහා iterations ගාණක් එන්න එපැයි. එහෙම වෙන කිසිම pattern එකක් නෑ.

    මේක conjecture එකට proof එකක් නෙවෙයි. හැබැයි අර මනුස්සයා අන්තිමට කියන එන්න එන්නම linear වෙන කතාවට හොඳම නිදසුනක්. එක දිගටම ලොකු ගණන් දාලත් iterations ගාණ චූටියි නම් අපිට කොච්චර ලොකු ගාණක් දැම්මත් 1 ට එන්න යන steps ගාණ ඊට වඩා සෑහෙන අඩුයි කියලා ගන්න පුළුවන්. ඉතින් සාධනයක් නොවුණත් මේක ඉතාම හොඳ අපෝහනයක්.

    මේක phone එකකින් වුණත් මිලියන ගාණක් brute force check කරන්න පුළුවන්. යටින් උදාහරණයක් තියෙනවා. 👍

    def testing(Num):
    Iteration=1
    while Num > 1:
    if Num%2 == 1:
    Num = 3*Num+1
    Iteration+=1
    else:
    Num = Num/2
    Iteration+=1
    return(Iteration)
    Highest=0
    X = 1
    while True:
    Limit = int(input("what? :"))
    while X < Limit:
    if testing(X) > Highest:
    Highest = testing(X)
    X+=1
    print(Highest)

    මෙන්න code එක syntax එක්ක සහ run කරාම එන iterations ගාණ. (එළකිරි හුත්තෙ code indentation හරියට එන් නැහැ.) ප්‍රස්තාරයක් අ‍ැන්දා නම් ඕන එකෙක්ට සිද්ධිය තේරෙයි. 👍

    මමත් ඕක කරලා ඊයේ අතෑරියා. උබේ ඔය මෑත ටර්ම්ස් නම් මට තේරෙන්නේ නැ . හැබැයි උබ සරලව කියන්නේ සංක්‍යාවක් දැම්මම එකේ 1 එන්න කලින් ඉටෙරෂන් කියක් ගියාද කියන එකනේ? එක උබ 10 ත් බලෙකට යනකන් කරලා එකේ එන අගයන් ප්‍රස්තාරේක දාන්න කතාවක් නේ කියන්නේ නේද?
     
    • Like
    Reactions: Ridunapm