Results 1 to 1 of 1

Thread: simple math problem but impossible to solve

  1. #1

    simple math problem but impossible to solve

    Choose any positive integer and call it N.
    If the number is odd, triple it and add 1, or in other words replace N by 3N + 1.
    If the number is even, divide it by 2, replacing N by N /2
    continue this procedure until the result converge to 1
    the problem is that no one is able to device an algorithm to know how much steps needs to converge to 1. no general solution has been devised.
    https://www.math.hmc.edu/funfacts/ffiles/10008.5.shtml
    http://mathworld.wolfram.com/HailstoneNumber.html

    look article from 1984
    http://s000.tinyupload.com/index.php...99852244428304

    Uses "Console"
    
    String s, a
    Long n
    Long i, test
    
    For test = 1 To 10000
    n = 0: i = 0
    
    PrintL "write the number under investigation "
    s = Console_ReadLine()
    n = Val(s)
    If n = 0 Then Exit For
    For i=1 To 1000000
    
    If Mod(n,2)=0 Then
     n=n/2
     Else
     n=n*3+1
    EndIf 
    Print Str$(n) + " "
    If n=1 Then Exit For
    Next 
    PrintL
    Print "number of iterations = " +Str$(i)
    PrintL
    PrintL "  Press q to end program any other key to continue testing"
    s = Console_ReadLine()
    If s = "q" Then Exit For
    Next
    
    Last edited by primo; 16-08-2018 at 09:10.

Similar Threads

  1. what is wrong with using this PB DLL, and how to solve it
    By primo in forum thinBasic General
    Replies: 4
    Last Post: 16-01-2017, 11:47
  2. Uploads impossible?
    By ReneMiner in forum Shout Box Area
    Replies: 7
    Last Post: 15-07-2013, 23:11
  3. simple math.calculator + verify numbers AND characters possible ?
    By Lionheart008 in forum UI (User Interface)
    Replies: 12
    Last Post: 15-09-2010, 18:09
  4. Problem with matrix math routine for DETERMINANTS
    By GSAC3 in forum Preview testing
    Replies: 3
    Last Post: 01-09-2008, 01:34

Members who have read this thread: 0

There are no members to list at the moment.

Posting Permissions

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