# Thread: Old pseudo random number generator

1. ahahahahah

If I use Excel 2013 I get same result as Script Basic
If I use VBA for Excel 2013 I get same result as thinBasic

Also tested Power Basic I get same result as thinBasic

2. Too funny!

3. if we try to see a pattern using what is like Ulam primes spiral, but checking if Round(R,2)= 0.12 as an example we will see a pattern, change 0.12 to 0.13 and another pattern and so on.
but it appears the same number of its 6 digits such as (0.181763) does not recur at all or we need a super computer to check this.
using example primeNumbers in thinbasic examples:

B=(A+R)^8
R=B-Int(B)

If Round(R,2)=0.12 Then
Canvas_Color(Rgb(0, 255, 255))
Canvas_SetPixel(x/3, y/3)

the purpose of (x/3, y/3) is to compress the graph only
```
Uses "UI"

'-----------------------------------------------------------
' Global variables
'-----------------------------------------------------------
Dim ScreenWidth     As Long = 800
Dim ScreenHeight    As Long = 800
Dim t1, t2          As Quad         '---For time measuring
Dim i, j            As Long         '---Loopers
Dim x, y, dots      As Long         '---
Dim turn            As Long = 0     '---
Dim num             As Long = 1     '---Prime number starting point
Dim points_per_edge As Long = 1     '---
Dim edgecycle       As Long = 0     '---

Dim hWin            As DWord        '---Handle of the canvas window

'-----------------------------------------------------------
' Main program
'-----------------------------------------------------------
hWin = Canvas_Window("experiments ...", 1, 1, ScreenWidth, ScreenHeight )

Canvas_Attach(hWin, 0, %TRUE) ' <- double buffer

timebeginperiod(1)

'---Start timer
HiResTimer_Init
t1 = HiResTimer_Get

'---Init canvas
Canvas_Clear(%BLACK)
Canvas_Box(1, 1, ScreenWidth-1, ScreenHeight-1, 5, Rgb(255,255, 0))

'---Starting point
x = ScreenWidth / 1
y = ScreenHeight / 1
Global A,B,R As Single
'Global A,B,R As Double'Single
A=4
A=A/3

'---Main Prime number looper
For i = 1 To 3000
Plotting()
Next

'---Ending timer
t2 = HiResTimer_Get

Canvas_SetPos 10, ScreenHeight - 20
Canvas_Color(%WHITE, %BLACK)
Canvas_Print "Time taken: " + Format\$((t2 - t1) / 1000000, "#.000") + " second - " + _
dots + " dots drawn. Press a key to continue."

'---A last redraw
Canvas_Redraw

timeendperiod(1)

Canvas_WaitKey
Canvas_Window End

'-----------------------------------------------------------
Sub Plotting()
'-----------------------------------------------------------
B=(A+R)^8
R=B-Int(B)

Static IsTimeToRedraw As Long

Incr IsTimeToRedraw
If Mod(IsTimeToRedraw, 20) = 0 Then Canvas_Redraw

turn += 1
If turn = 5 Then turn = 1
edgecycle += 1

If edgecycle = 3 Then
edgecycle = 1
points_per_edge += 1
'Canvas_Redraw
End If

For j = 1 To points_per_edge
num += 1

Select Case turn
Case 1
x = x + 1
Case 2
y = y - 1
Case 3
x = x - 1
Case 4
y = y + 1
End Select

'If IsPrime(num) Then
If Round(R,2)=0.12 Then
Canvas_Color(Rgb(0, 255, 255))
Canvas_SetPixel(x/3, y/3)
dots += 1
End If

Next

End Sub
```

4. I decided to give our little random program a try under Windows 32 bit Script BASIC. I also changed the FORMAT mask to use %f instead of %g.

Not so random to me.

```' generates random #'s 0< x <1
20 SPLIT "4,0,0" BY "," TO A,I,R
30 LET A=A/3
50 LET B=(A+R)^8
60 LET R=B-INT(B)
70 LET I=I+1
80 IF I>10 THEN GOTO 110
90 PRINT FORMAT("%f",R),"\n"
100 GOTO 50
110 LET I=0
120 END
```
Windows 32

0.988721
0.238686
0.296148
0.704405
0.294489
0.301148
0.937858
0.994102
0.034326
0.241162

Linux 64

0.988721
0.238686
0.296148
0.704405
0.294489
0.301148
0.937858
0.994102
0.034326
0.241162

This is ProvideX Business BASIC - Windows 32 bit

```-:list
0010 REM generates random #'s 0< x <1
0015 PRECISION 6
0020 LET A=4
0030 LET A=A/3
0050 LET B=(A+R)^8
0060 LET R=B-INT(B)
0070 LET I=I+1
0080 IF I>10 THEN GOTO 0110
0090 PRINT R
0100 GOTO 0050
0110 LET I=0
0120 END
-:run
.016866
.045421
.05853
.085489
.421897
.089104
.759626
.201681
.824691
.381424
-:
```
Here is Minimal BASIC.

```C:\bas55v116>bas55
bas55 1.16

This is free software: you are free to change and redistribute it,
but there is NO WARRANTY. Type LICENSE to show the details.

Type HELP for a list of allowed commands.
random.bas
list
20 LET A=4
21 LET R=0
22 LET I=0
30 LET A=A/3
50 LET B=(A+R)^8
60 LET R=B-INT(B)
70 LET I=I+1
80 IF I>10 THEN 110
90 PRINT R
100 GOTO 50
110 LET I=0
120 END
run
.988721
.238686
.296148
.704404
.293924
.164322
.31015
.225925
.941762
.787928
quit

C:\bas55v116>
```

Page 2 of 2 First 12

#### Posting Permissions

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