mercredi 9 juin 2021

Split a Number into multiple numbers with an increasing pattern

Hopefully I make sense. I want something like this. Consider, Total = 10

I want to divide Total into 5 parts

[n,n,n,n,n]

(If we add all numbers in this array it results to 10 )


Now suppose the increment pattern is Step = 2%

so it should be like

[n, n + 2%, n + 4%, n + 6%, n + 8%]

(adding all should result to 10)

I found this answer, but unable to add the increment pattern - Split number into 4 random numbers

Thanks a lot for reading my question :), wish someone can help...




Aucun commentaire:

Enregistrer un commentaire