Jackson Structured Progamming
Question and answer in Quora:

The sum of the first 3 terms is 33 and the sum if the first 6 terms is 120. What is the first term and common difference?
Hi!

I am designing, that is, sketching a proposal for a program that will give us the answers! For each value of a = first term and the common difference d, we are investigating, whether both equations are true! You are talking about an arithmetic series here.

Poe says this:

This question is about an arithmetic sequence. In an arithmetic sequence, each term increases by a constant difference, called the common difference. To solve this task, we need to find the first term and the common difference in the number sequence. We are given the following information: - The sum of the first 3 terms is 33 - The sum of the first 6 terms is 120 Let's call the first term "a" and the common difference "d". So for the first 3 terms we have: a + (a + d) + (a + 2d) = 33 And for the first 6 terms we have: a + (a + d) + (a + 2d) + (a + 3d) + (a + 4d) + (a + 5d) = 120 By solving these two equations, we can find the values of "a" and "d".

And I mean this;

As usual, we look at the user data involved. User data helps us keep our thoughts under control in such a way that they become a stable handle to hold on to during all steps of the design process.That is, we are investigating. whether both equations are true at the same time as above. We then get 1 or more iterations where both equations are false. Until we suddenly find values of a and d where both are true. The absolute last iteration of the equation structures.

We will successively obtain function values for the two evations that are lower than those specified. And suddenly we get some function value that has exceeded the specified ones. Thus reaching above the maximum values. Then we have to start over with the next a and consequently restart d from the beginning again. If we have reached the exact equation values 33 and 120, we stop the machine and report the a and d values! We have the following operations - (sketch)

1 - set a to 1. P2

2 - set a up by 1.P2

3 - set d to 1. P2

4 - set d up by 1. P2

5 - print the roots a and d. P1

6 - read Nf-giveme-next-a-d-rec-i. P2

10 write first Nf-giveme next-a-d-record-o,. P1

11. Write next Nf-giveme-next-a-d-record-o, P1

Condition.

Quit operations P1

Q2 if eq-1 > 33 or eq-2 > 120 [ limit d]

.Q1 if eq-1 true (=33) and eq-2 true.(=120).

I take and divide the whole thing into two processes. P1 which handles the equation structures to find the a and d values, which make both equations true at the same time. P2 supports in that work, by tirelessly at P1's request ( write ) delivering the values, a from 1 upwards and for each a delivering d values from 1 upwards until one of the equations exceeds the function (limit) values 33 or 120 . With two separate objects, we separate the handling /iteration of the equation structure from the iterations with the a and values. There will be small, very nice diagrams for data streams and the processes for P1 and P2 respectively. The notational file Nf-next-a-d connects P1 and P2 and contains the entries "give me" in turn, entries of the types: "first a", "first d", next d, next d, next a, first d , next d….. etc. Ex: 1,1 1,2, 1,4 - 2,1, 2,2 2,3…..So equation 1 represents the first 3 terms and the difference. And number 2, the first 6 terms. So each equation is evaluated for each pair of a,d.

Note! The photo at the bottom is my sketch to arrive at a small solution. Thoughts go here and there. I try many options during the trip. Maybe not that much to worry about!

Bengt