Repeat number with total

Hi, All

i have a basic three data (A) 500, (B) 4250 & © 3.

i want to add number of B(4250) in A (500)= 4750 is Total. then again this process 4750 + B (4250) = 9000 & then again 9000 + B (4250) = 13250. this process is very lengthy.

i have main 3 data A,B & C, C is a repeated number for B.

please suggest me how to solve this problem.

Hello
like this?

No,
below like this.

  1. 4750
  2. 9000
  3. 13250

try this

def repeatAddValue(initValue, valueAdd, repeat):
	if repeat > 0:
		repeat -= 1
		sumNum = initValue + valueAdd
		return [sumNum] + repeatAddValue(sumNum, valueAdd, repeat)
	else:
		return	[]


OUT = repeatAddValue(IN[0], IN[1], IN[2])
3 Likes

Depending on what your doing and how much control/variation you need this could be a option for you.

3 Likes

Thanks c.poupin :smiley: :smiley: :+1: :+1:

1 Like

Thanks Brendan_Cassidy for another options. :+1: :+1:

1 Like

Using Design Script …

def sumTotal (a,b,c)
{
	return = [Imperative]
	{
		d = [a + b];
		for (i in 1..c)
		{
			f = List.LastItem(d) + b;
			d[i] = f;
		}
		return d;
	}
};

sumTotal (500,4250,9);
5 Likes

Realized that you just need a sequence :grimacing:
Using nodes …
sumTotal_2020-09-30_09-38-07

Or a line of code …
List.RestOfItems(500..#10..4250);

sumTotal_2020-09-30_09-37-51

2 Likes