+ Reply to Thread
Results 1 to 3 of 3

Mapping the Collatz Conjecture in Excel

  1. #1
    Registered User
    Join Date
    07-01-2022
    Location
    London, England
    MS-Off Ver
    Microsoft 365
    Posts
    1

    Post Mapping the Collatz Conjecture in Excel

    Hi guys, I was wondering if I could get some help as I'm not particularly proficient on Excel.

    My excel problem is regarding a specific mathematical phenomenon called the 'Collatz Conjecture'

    (For those who don't know the Collatz Conjecture, it is a mathematical problem where from whichever starting number you're at you multiply the number by 3 and add 1 if it's an odd number, if it is an even number you divide by 2. Eventually all of these sequences end up going back to the number 1.

    There is a video by Veritasium on their youtube channel explaining the problem if you would prefer a fuller explanation, it is called: 'The Simplest Math Problem No One Can Solve - Collatz Conjecture')

    I need to make a document which lists every number of the Collatz Conjecture sequence for the numbers between 1 - 131072.

    With Row 1 being for the number 1, row 2 for number 2 etc...

    Example (Row 3): Column A = 3, B = 10, C = 5, D = 16, E = 8, F = 4, G = 2, H = 1. We stop here as the sequence has reached 1.

    However, the moment any sequence exceeds the number 131072, the cells in that row must be blank from that point on.

    For example the sequence starting with 129,198 (which would be row 129,198):

    A - 129,198
    B - 64,599
    C - 193,796 (at this point we have a value that exceeds 131,072 hence this cell should be empty)
    D - empty cell
    E - empty cell
    F - empty cell
    Etc...

    I was hoping someone could guide me as to how to construct this excel spreadsheet, or if anyone has time on their hands and feels that it is a relatively simple exercise for them, to construct the spreadsheet for me and post it.

    Apologies for the long text and thanks in advance
    Last edited by AliGW; 07-01-2022 at 11:40 AM.

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,758

    Re: Mapping the Collatz Conjecture in Excel

    Welcome to the forum.

    There are instructions at the top of the page explaining how to attach your sample workbook.

    A good sample workbook has just 10-20 rows of representative data that has been desensitised. It also has expected results mocked up, worked examples where required, relevant cells highlighted and a few explanatory notes.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,819

    Re: Mapping the Collatz Conjecture in Excel

    I'm not sure what part of programming this you are having trouble with. In Excel, it seems like it is mostly just a sequence of nested IF() functions that represents the desired logic. If you are unfamiliar with Excel's IF() function: https://support.microsoft.com/en-us/...c-aa8bbff73be2

    1) Enter a starting value in A1.
    2) In A2, build the desired nested IF() function:
    2a) I start with the innermost test IF(ISEVEN(A1),A1/2,A1*3+1). If you are unfamiliar with the ISEVEN() function: https://support.microsoft.com/en-us/...4-2f479af55356 Also note that there is an ISODD() function if you would prefer to invert this IF() test.
    2b) Nest that inside of an IF() test for previous value larger than max. IF(A1>131072,0,IF(ISEVEN(A1),...)). Note here that I chose 0 as the output rather than null string because 0 will propagate to the end without the need for another level of IF() testing. If you decide that it must output null string, then you can simply add another level of testing that propagates the null string to the bottom.
    2c) Nest that inside of a test for the final 1 result =IF(A1=1,A1,IF(A1>131072,...))
    3) Copy/paste/fill that formula down as far as needed for the longest expected sequence.

    Mostly just a sequence of IF() functions. Any questions on how that goes into the spreadsheet?
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Collatz conjecture
    By candicee in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 12-25-2017, 05:04 PM
  2. Mapping in Excel
    By redJohn89 in forum Excel General
    Replies: 2
    Last Post: 03-12-2017, 01:08 PM
  3. Excel - XML mapping.
    By Bunta in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-10-2013, 05:57 AM
  4. mapping with excel
    By Gord Dibben in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-06-2005, 04:05 AM
  5. mapping with excel
    By silvarisbrett in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 02:05 AM
  6. [SOLVED] mapping with excel
    By silvarisbrett in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 12:05 AM
  7. [SOLVED] mapping with excel
    By silvarisbrett in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-05-2005, 10:05 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1