Home > front end >  Create a google sheet SEQUENCE with given sum of numbers
Create a google sheet SEQUENCE with given sum of numbers

Time:11-28

Need help:

I have a number (let's say 550) and need to create a perfect distributed SEQUENCE of length N where SUM of numbers will give this number (550).

Something like: 10, 20, 30, 40, 50, 60, 70, 80, 90, 100

The only input I have is the length of sequence and the final sum of it's numbers.

Thank you.

CodePudding user response:

if your issue is to divide value x into equal chunks y try:

=INDEX(SEQUENCE(B1, 1)*A1/B1)

enter image description here

or starting from 0:

=INDEX(SEQUENCE(B1, 1, 0)*A1/(B1-1))

enter image description here

CodePudding user response:

So here are some possible starting values (a) and increments (d) that satisfy the conditions where the number of terms n is 10 and the sum S is 550:

Using the formula

=MAKEARRAY(S/n,2,LAMBDA(r,c,if(c=1,r,2/(n-1)*(S/n-r))))

The formula is obtained by re-arranging the enter image description here

enter image description here

Here are the integer pairs using

=lambda(pairs,filter(pairs,index(pairs,,2)=int(index(pairs,,2))))(MAKEARRAY(S/n,2,LAMBDA(r,c,if(c=1,r,2/(n-1)*(S/n-r)))))

enter image description here

Here are the actual series using

=lambda(intpairs,makearray(rows(intpairs),n,lambda(r,c,index(intpairs,r,1) (c-1)*index(intpairs,r,2))))(lambda(pairs,filter(pairs,index(pairs,,2)=int(index(pairs,,2))))(MAKEARRAY(S/n,2,LAMBDA(r,c,if(c=1,r,2/(n-1)*(S/n-r))))))

enter image description here

It can be verified that each series totals to 550.

Once you have the values of a and d, you can also use Sequence to generate the results:

=sequence(1,n,F10,G10)

enter image description here

  • Related