Variable Sequence Problem

Joined
May 1, 2023
Messages
7
Reaction score
1
Hello All,
I need to breakdown an algorithm on pen and paper, but I am having trouble with it since it is not an arithmetic sequence problem. I broke down the pattern but still I am having trouble coming up with an algorithm for it. Can anybody please help.
Thank you!
 

Attachments

  • Page1.png
    Page1.png
    391.5 KB · Views: 27
  • Page2.png
    Page2.png
    358.1 KB · Views: 28
Joined
Sep 21, 2022
Messages
167
Reaction score
24
Code:
1: 01
2: 0223
3: 024345
4: 02464567
5: 0246856789

Split every line.

1: 0     1
2: 02    23
3: 024   345
4: 0246  4567
5: 02468 56789

2n-2 gives 0,2,4,6,8

2n-1 gives 1,3,5,7,9

REM BASIC demonstration
FOR N=1 TO 5
 S=""
 A=(2*N)-2
 B=(2*N)-1
 FOR I=0 TO A STEP 2
  S+=STR(I)
 NEXT
 FOR I=N TO B STEP 1
  S+=STR(I)
 NEXT
 ? N;" ";S
NEXT
 
Joined
May 1, 2023
Messages
7
Reaction score
1
WhiteCube you are awesome!!! The question really confused me because it said executing an algorithm which I thought there was one algorithm; however, seeing your answer it makes much sense!!!
Thank you!!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,153
Members
46,699
Latest member
AnneRosen

Latest Threads

Top