How to resolve the algorithm Klarner-Rado sequence step by step in the EasyLang programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Klarner-Rado sequence step by step in the EasyLang programming language
Table of Contents
Problem Statement
Klarner-Rado sequences are a class of similar sequences that were studied by the mathematicians David Klarner and Richard Rado. The most well known is defined as the thinnest strictly ascending sequence K which starts 1, then, for each element n, it will also contain somewhere in the sequence, 2 × n + 1 and 3 × n + 1.
So, the sequence K starts with 1. Set n equal to the first element 1; the sequence will also contain 2 × n + 1 and 3 × n + 1, or 3 and 4. Set n equal to the next element: 3, somewhere in the sequence it will contain 2 × n + 1 and 3 × n + 1, or 7 and 10. Continue setting n equal to each element in turn to add to the sequence.
Preferably without needing to find an over abundance and sorting.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Klarner-Rado sequence step by step in the EasyLang programming language
Source code in the easylang programming language
m2 = 1
m3 = 1
for o = 1 to 1000000
if m2 < m3
m = m2
else
m = m3
.
klarner_rado[] &= m
if m2 = m
i2 += 1
m2 = klarner_rado[i2] * 2 + 1
.
if m3 = m
i3 += 1
m3 = klarner_rado[i3] * 3 + 1
.
.
for i = 1 to 100
write klarner_rado[i] & " "
.
print ""
print ""
i = 1000
while i < o
write klarner_rado[i] & " "
i *= 10
.
You may also check:How to resolve the algorithm Law of cosines - triples step by step in the C# programming language
You may also check:How to resolve the algorithm Cartesian product of two or more lists step by step in the PicoLisp programming language
You may also check:How to resolve the algorithm File input/output step by step in the Vedit macro language programming language
You may also check:How to resolve the algorithm Exponentiation operator step by step in the Nemerle programming language
You may also check:How to resolve the algorithm Biorhythms step by step in the C programming language