Given the triangle of consecutive odd numbers:

```
             1
          3     5
       7     9    11
   13    15    17    19
21    23    25    27    29
...
```

Calculate the row sums of this triangle from the row index (starting at index 1) e.g.:

```python
row_sum_odd_numbers(1); # 1
row_sum_odd_numbers(2); # 3 + 5 = 8
```

```if:nasm
row_sum_odd_numbers:
```

Difficulty: EASY
Starter code: def row_sum_odd_numbers(n):
	

Solutions:
def row_sum_odd_numbers(n):
	return n ** 3


def row_sum_odd_numbers(n):
	if type(n) == int and n > 0:
		return n ** 3
	else:
		return 'Input a positive integer'


def row_sum_odd_numbers(n):
	return n * n * n


def row_sum_odd_numbers(n):
	return pow(n, 3)


def row_sum_odd_numbers(n):
	(a, b) = (n * (n - 1) + 1, n * (n + 1))
	return sum(range(a, b, 2)) if a != 1 else 1


def row_sum_odd_numbers(n):
	return sum(range(n * (n - 1) + 1, n * (n + 1), 2))


def row_sum_odd_numbers(n, base=2):
	first_num = n * (n - 1) + 1
	numbers = range(first_num, first_num + base * n, base)
	return sum(numbers)


def row_sum_odd_numbers(n):
	sum = 0
	num = n * n + n - 1
	for i in range(n):
		sum += num
		num -= 2
	return sum


row_sum_odd_numbers = lambda n: n ** 3


def row_sum_odd_numbers(n):
	x = []
	for i in range(1, n * n + n, 2):
		x.append(i)
	return sum(x[-n:])


def row_sum_odd_numbers(n):
	m = (n - 1) * n + 1
	o = m
	while n > 1:
		m = m + 2
		o = o + m
		n = n - 1
	return o


def row_sum_odd_numbers(n):
	prev = 1
	ll = [y * [0] for y in range(1, n + 1)]
	for x in ll:
		for i in range(len(x)):
			x[i] = prev
			prev += 2
	return sum(ll[-1])


def row_sum_odd_numbers(n):
	return sum([i for i in range(sum([i for i in range(1, n + 1)]) * 2) if i % 2][:-n - 1:-1])


def row_sum_odd_numbers(n):
	(sum, sum2, h, k, i, s1, s2) = (0, 0, n - 1, -1, 0, 0, 0)
	while n != 0:
		sum += n
		n -= 1
	while h != 0:
		sum2 += h
		h -= 1
	while i <= sum - 1:
		if i == sum2:
			s2 = s1
		k += 2
		s1 += k
		i += 1
	return s1 - s2


def row_sum_odd_numbers(n):
	a = [y * [False] for y in range(1, n + 1)]
	odds = iter(list(range(1, 10 ** 6, 2)))
	return sum([[next(odds) for c in x if c is False] for x in a][-1])


def row_sum_odd_numbers(n):
	return n * (n + n * (n - 1))


def row_sum_odd_numbers(n):
	stop = sum(range(n + 1))
	start = sum(range(n)) + 1
	return sum(range(start + start - 1, stop + stop, 2))


def row_sum_odd_numbers(n):
	x = 1
	r = 1
	inc = 2
	s = 0
	for i in range(1, n):
		x += inc
		r += 1
		inc += 2
	for j in range(r):
		s += x
		x += 2
	return s


def row_sum_odd_numbers(n: int):
	return sum([_ for _ in range(n * (n - 1), n * (n - 1) + n * 2) if _ % 2])


def row_sum_odd_numbers(n):
	return ((n - 1) ** 2 + n) * n + n * (n - 1)


def row_sum_odd_numbers(n):
	a = n
	return a * a * a


def row_sum_odd_numbers(row):
	total = 0
	for i in range(1, row + 1):
		total += 1 * i
	sum = 0
	lastInt = total * 2 - 1
	startInt = lastInt - (row - 1) * 2 - 1
	for i in range(lastInt, startInt, -2):
		sum += i
	return sum


row_sum_odd_numbers = lambda n: n * n * n


row_sum_odd_numbers = 3 .__rpow__


def row_sum_odd_numbers(n):
	x = 1
	c = 0
	final = 0
	for e in range(n):
		x += c
		c += 2
	for d in range(n):
		final += x
		x += 2
	return final


def row_sum_odd_numbers(n):
	first = n * (n - 1) + 1
	return first * n + n * (n - 1)


def row_sum_odd_numbers(n):
	return sum([x * 2 - 1 for x in list(range(n * (n + 1) // 2 - n + 1, n * (n + 1) // 2 + 1))])


import numpy as np

def row_sum_odd_numbers(n):
	return sum(np.linspace(n ** 2 - (n - 1), n ** 2 + n - 1, n))


def row_sum_odd_numbers(n):
	if n < 1:
		return 0
	else:
		return n * n * n


def row_sum_odd_numbers(n):
	start = sum(range(1, n))
	end = start + n
	return sum([i for i in range(1, end * 2, 2)][start:end])


def row_sum_odd_numbers(n):
	formula = n ** 3
	return formula


def row_sum_odd_numbers(n):
	row_generator = generate_row(n)
	sum = 0
	for val in row_generator:
		sum += val
	return sum

def generate_row(i: int):
	start = i * (i - 1) + 1
	row_length = i
	for num in range(row_length):
		yield start
		start += 2


def row_sum_odd_numbers(n):
	return sum([n for n in range(n * (n + 1)) if n % 2 != 0][-n:])


def row_sum_odd_numbers(n):
	num_pos = find_numb_count(n)
	sum = 0
	for i in range(n):
		sum += num_pos * 2 - 1
		num_pos -= 1
	return sum

def find_numb_count(n):
	if n == 1:
		return 1
	return find_numb_count(n - 1) + n


def row_sum_odd_numbers(n):
	return sum((n * (n - 1) + 1 + a * 2 for a in range(n)))


def row_sum_odd_numbers(n):
	if n < 1:
		return None
	return n ** 3


def row_sum_odd_numbers(n):
	row_start = (n - 1) * n + 1
	return sum([x for x in range(row_start, row_start + n * 2, 2)])


def row_sum_odd_numbers(n):
	f = n * (n - 1) / 2 - 1
	s1 = (f + 1) * (f + 1)
	s2 = (f + n + 1) * (f + n + 1)
	return s2 - s1


def row_sum_odd_numbers(n):
	i = n
	numberx = 0
	while n > 0:
		numberx += n
		n -= 1
	v = numberx
	resultList = []
	result = 0
	for x in range(1, numberx * 2 + 1):
		if x % 2 == 1:
			resultList.append(x)
	while v > numberx - i:
		result += int(resultList[v - 1])
		v -= 1
	return result


def row_sum_odd_numbers(n):
	if n == 1:
		return 1
	else:
		min_odd_in_row = n * (n - 1) + 1
		max_odd_in_row = n * (n + 1) - 1
		return n * (max_odd_in_row + min_odd_in_row) / 2


def row_sum_odd_numbers(n):
	for i in range(n):
		if n == 1:
			return n
		else:
			return n ** 3


def row_sum_odd_numbers(n):
	numofnums = 0
	for i in range(1, n + 1):
		numofnums += i
	oddints = [2 * x + 1 for x in range(numofnums)]
	return sum(oddints[-n:])


def row_sum_odd_numbers(n):
	if n == 1:
		return 1
	my_list = list(range(1, n * (n + 1), 2))
	return sum(my_list[n * -1:])


def row_sum_odd_numbers(n):
	num1 = n * (n - 1)
	num1 += 1
	i = 0
	sum = 0
	while i < n:
		num2 = 0
		num2 = num1 + i * 2
		sum += num2
		i += 1
	return sum


def row_sum_odd_numbers(n):
	start = 1
	for z in range(n):
		start += 2 * z
	sum_of_odd = 0
	for i in range(1, n + 1):
		sum_of_odd += start
		start += 2
	return sum_of_odd


def row_sum_odd_numbers(n: int) -> int:
	num_of_records = n * (n + 1) // 2
	return sum([2 * i - 1 for i in range(num_of_records - n + 1, num_of_records + 1)])


def row_sum_odd_numbers(n):
	return sum([n * (n - 1) + 1 + 2 * k for k in range(n)])


def row_sum_odd_numbers(n):
	total_nums = sum(range(0, n + 1))
	num_array = []
	count = 1
	while True:
		if count % 2 != 0:
			num_array.append(count)
		if len(num_array) == total_nums:
			break
		count += 1
	return sum(num_array[-n:])


def row_sum_odd_numbers(n):
	counter = 0
	for i in range(1, n + 1):
		sum_list = []
		switch = 0
		while switch != i:
			if counter % 2 != 0:
				switch += 1
				sum_list.append(counter)
			counter += 1
	return sum(sum_list)


def row_sum_odd_numbers(n):
	k = sum(range(n))
	count = 0
	start = 1 + k * 2
	sum_i = 0
	while count < n:
		sum_i += start
		start += 2
		count += 1
	return sum_i


def row_sum_odd_numbers(n):
	triNumber = n * (n + 1) / 2
	totalOdd = triNumber ** 2
	previousRow = n - 1
	previousTriNumber = previousRow * (previousRow + 1) / 2
	totalOddPrevious = previousTriNumber ** 2
	return totalOdd - totalOddPrevious


def row_sum_odd_numbers(n):
	k = int((1 + n) * n / 2)
	m = int((1 + n - 1) * (n - 1) / 2)
	if k == 1:
		return 1
	x = 0
	y = 0
	z = 0
	w = 0
	for i in range(k):
		if i == 0:
			x = 1
		else:
			x = x + 2
		z = z + x
	for i in range(m):
		if i == 0:
			y = 1
		else:
			y = y + 2
		w = w + y
	return z - w


def row_sum_odd_numbers(n):
	num = 1
	for x in range(n):
		num = num + 2 * x
	total = 0
	for x in range(n):
		total += num + 2 * x
	return total


def row_sum_odd_numbers(n):
	num_add = n * (n + 1) / 2
	last = num_add * 2 - 1
	first = last + 2 * (1 - n)
	return (first + last) * (n / 2)


def row_sum_odd_numbers(n):
	m = (1 + n) * n / 2
	l = 1 + (m - 1) * 2
	q = (1 + l) * m / 2
	p = (1 + 1 + (m - n - 1) * 2) * (m - n) / 2
	return q - p


def row_sum_odd_numbers(n):
	triangle = []
	odd = 1
	for row in range(n):
		triangle.append([])
		while len(triangle[row]) < row + 1:
			triangle[row].append(odd)
			odd += 2
	return sum(triangle[n - 1])


def row_sum_odd_numbers(n):
	if n == 1:
		return 1
	else:
		nums = list(range(sum(range(n * 2))))
		val = sum(range(n))
		return sum(list((num for num in nums if num % 2 != 0))[val:val + n])


def row_sum_odd_numbers(n):
	a = 0
	o = 0
	e = 0
	for x in range(1, n + 1):
		a += x
	for y in range(1, 2 * a, 2):
		o += y
	for z in range(1, 2 * (a - n), 2):
		e += z
	return o - e


def row_sum_odd_numbers(n):
	row_start_num = (n - 1) * n + 1
	row_sum = n * row_start_num + n * (n - 1)
	return row_sum


def row_sum_odd_numbers(n):
	digits_counter = sum(range(n + 1))
	triangle_content = []
	while len(triangle_content) != digits_counter:
		for i in range(digits_counter * 2 + 1):
			if i % 2 == 1:
				triangle_content.append(i)
	final_sum = 0
	for digit in triangle_content[len(triangle_content) - n:]:
		final_sum += digit
	return final_sum


def row_sum_odd_numbers(n):
	lenth = n
	counter = 0
	while n > 0:
		print((n, counter))
		counter += n
		n -= 1
	return sum(range(1, counter * 2, 2)[-lenth:])


def row_sum_odd_numbers(num_line):
	sum_permid = 0
	first_line = num_line * (num_line - 1) + 1
	stop_line = first_line + num_line * 2
	for j in range(first_line, stop_line, 2):
		sum_permid += j
	return sum_permid


def row_sum_odd_numbers(n):
	min = n ** 2 - n + 1
	max = n ** 2 + n - 1
	sum = 0
	while min <= max:
		if min % 2 == 1:
			sum = sum + min
			min += 2
	return sum


def row_sum_odd_numbers(n):
	start = n ** 2 - n + 1
	stop = start + n * 2
	return sum((x for x in range(start, stop, 2)))


def row_sum_odd_numbers(n):
	count = 0
	kokosik = 1
	result = 0
	for huesosina in range(0, n):
		kokosik += count
		count += 2
	result += kokosik
	for guccigang in range(0, n - 1):
		kokosik += 2
		result += kokosik
	return result


def row_sum_odd_numbers(n):
	first_num = 1 + n * (n - 1)
	last_num = first_num + 2 * (n - 1)
	new_list = [x for x in range(first_num, last_num + 1) if (x + 1) % 2 == 0]
	return sum(new_list)


def row_sum_odd_numbers(n):
	c = 0
	for i in range(n + 1):
		c += i
	if c > 1:
		index = 1
		a = []
		for j in range(c):
			a.append(index)
			index += 2
		s = 0
		e = c - n
		while c != e:
			s += a[c - 1]
			c -= 1
		return s
	else:
		return n


def row_sum_odd_numbers(n):
	s = 0
	a1 = 1 + n * (n - 1)
	for i in range(n):
		s += a1
		a1 += 2
	return s


def row_sum_odd_numbers(n):
	if n == 0:
		return 0
	last_odd = n * (n + 1) / 2
	prev_last_odd = (n - 1) * n / 2
	return last_odd * last_odd - prev_last_odd * prev_last_odd


def row_sum_odd_numbers(n):
	(row, x) = ([], 0)
	while x < n:
		row.append(n * (n - 1) + 1 + 2 * x)
		x += 1
	return sum(row)


def row_sum_odd_numbers(n):
	counter = 0
	start_number = 1
	end_number = 1
	sum_ = 1
	for i in range(n - 1):
		start_number += counter + 2
		end_number += counter + 4
		sum_ = sum([x for x in range(start_number, end_number + 2) if x % 2 != 0])
		counter += 2
	return sum_


def row_sum_odd_numbers(n):
	if n == 1:
		return 1
	startingdigit = (n - 1) * n + 1
	tot = startingdigit
	for i in range(1, n):
		startingdigit += 2
		tot += startingdigit
	return tot


def row_sum_odd_numbers(n):
	odd_number = n * (n - 1) + 1
	odd_numbers = []
	if n == 1:
		return n
	for idx in range(n):
		odd_numbers.append(odd_number)
		odd_number += 2
	return sum(odd_numbers)


def row_sum_odd_numbers(n):
	lista = []
	licznik = 0
	for i in range(n + 1):
		licznik = licznik + i
	for i in range(licznik):
		x = 2 * i + 1
		lista.append(x)
	return sum(lista[-n:])


def row_sum_odd_numbers(n):
	return sum([x for x in range(sum(range(1, n)) * 2, sum(range(1, n + 1)) * 2) if x % 2])


def row_sum_odd_numbers(n):
	odd_list = [1]
	max_odd = 1
	for x in range(1, n + 1):
		if x > 1:
			max_odd = max(odd_list)
			odd_list = [y for y in range(max_odd + 2, max_odd + 2 * x + 2, 2)]
	return sum(odd_list)


def row_sum_odd_numbers(n):
	a = (n - 1) ** 2 + n
	b = n ** 2 + n + 1
	return sum([i for i in range(a, b, 2)])


def row_sum_odd_numbers(n):
	data = {1: {'last': 1, 'sum': 1}}
	while max(data.keys()) <= n:
		id_max = max(data.keys())
		(last, summ) = (data[id_max]['last'], data[id_max]['sum'])
		a = [i for i in range(last + 2, id_max * 2 + last + 4, 2)]
		id_max += 1
		data[id_max] = {'last': a[-1], 'sum': sum(a)}
	return data[n]['sum']


def row_sum_odd_numbers(n):
	rowStart = n * (n - 1) + 1
	total = 0
	for i in range(n):
		total = total + (rowStart + 2 * i)
	return total


def row_sum_odd_numbers(n):
	startPoint = 1
	counter = 1
	mainNumber = 1
	sum = 0
	for num in range(n - 1, 0, -1):
		startPoint += num
	while counter < startPoint:
		if counter == startPoint:
			break
		else:
			mainNumber += 2
			counter += 1
	for i in range(mainNumber, mainNumber + n * 2, 2):
		sum += i
	return sum