Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Prime pattern 6 +/- 1
#7
This brutal program looks at a different issue but reminds me of what's going on here. It turns out that every odd number can be produced by a formula

a = (x * 2^y - 1) / 3

... for some pair x, y (as long as x is indivisible by 3). This particular relation is used to help say things about the Collatz conjecture if anyone wants to reverse engineer it. For some reason, this code runs slower in later versions of QB64, faster in the SDL version, and fastest in QBjs. Not even close to ready when tried in the BAM.

Code: (Select All)
'DefInt A-Z
Dim i, x, y, a, f, xlim, ylim
xlim = 1500
ylim = 1500
For i = 1 To 1001 Step 2
    f = 0
    x = 0
    Do While (f = 0) And (x < xlim)
        y = 0
        If (x Mod 3) <> 0 Then
            Do While (f = 0) And (y < ylim)
                a = (x * (2 ^ y) - 1) / 3
                If (a = i) Then
                    Print a; "= ("; _Trim$(Str$(x)); " * 2^"; _Trim$(Str$(y)); ") - 1) / 3"
                    f = 1
                End If
                If (f = 1) Then Exit Do
                y = y + 1
            Loop
            If (f = 1) Then Exit Do
        End If
        x = x + 1
    Loop
    If (f = 0) Then
        Print i; "Increase xlim or ylim."
        Beep
    End If
Next
Reply


Messages In This Thread
Prime pattern 6 +/- 1 - by SMcNeill - 06-30-2022, 10:49 AM
RE: Prime pattern 6 +/- 1 - by bplus - 06-30-2022, 12:25 PM
RE: Prime pattern 6 +/- 1 - by bplus - 06-30-2022, 12:29 PM
RE: Prime pattern 6 +/- 1 - by david_uwi - 06-30-2022, 12:46 PM
RE: Prime pattern 6 +/- 1 - by bplus - 06-30-2022, 01:32 PM
RE: Prime pattern 6 +/- 1 - by david_uwi - 06-30-2022, 02:39 PM
RE: Prime pattern 6 +/- 1 - by triggered - 07-01-2022, 11:29 AM
RE: Prime pattern 6 +/- 1 - by SMcNeill - 07-01-2022, 11:40 AM
RE: Prime pattern 6 +/- 1 - by bplus - 07-01-2022, 12:51 PM
RE: Prime pattern 6 +/- 1 - by bplus - 07-01-2022, 01:06 PM
RE: Prime pattern 6 +/- 1 - by bplus - 07-01-2022, 01:15 PM
RE: Prime pattern 6 +/- 1 - by david_uwi - 07-01-2022, 03:55 PM
RE: Prime pattern 6 +/- 1 - by triggered - 07-07-2022, 10:46 AM



Users browsing this thread: 7 Guest(s)