How to resolve the algorithm Thue-Morse step by step in the BASIC programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Thue-Morse step by step in the BASIC programming language

Table of Contents

Problem Statement

Create a Thue-Morse sequence.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Thue-Morse step by step in the BASIC programming language

Source code in the basic programming language

tm = "0"

Function Thue_Morse(s)
	k = ""
	For i = 1 To Length(s)
		If Mid(s, i, 1) = "1" Then
			k += "0"
		Else
			k += "1"
		End If
	Next i
	Thue_Morse = s + k
End Function

Print tm
For j = 1 To 7
	tm = Thue_Morse(tm)
	Print tm
Next j
End

 10 LET T$="0"
 20 PRINT "T0=";T$
 30 FOR I=1 TO 7
 40 PRINT "T";I;"=";
 50 FOR J=1 TO LEN T$
 60 IF T$(J)="0" THEN GOTO 90
 70 LET T$=T$+"0"
 80 GOTO 100
 90 LET T$=T$+"1"
100 NEXT J
110 PRINT T$
120 NEXT I


  

You may also check:How to resolve the algorithm Loops/Break step by step in the Quackery programming language
You may also check:How to resolve the algorithm Random number generator (included) step by step in the PureBasic programming language
You may also check:How to resolve the algorithm Move-to-front algorithm step by step in the PowerShell programming language
You may also check:How to resolve the algorithm Egyptian division step by step in the Mathematica/Wolfram Language programming language
You may also check:How to resolve the algorithm Tau function step by step in the COBOL programming language