For14. An integer N (>0) is given. Find the square of a given number, using the following formula to calculate it:
\(N^2 = 1 + 3 + 5 + ... + (2 \cdot N-1).\)
After adding to the sum of each term, output the current value of the sum (as a result, squares of all integers from 1 to N will be displayed).

Solution in Python 3:

import random

N = random.randrange(1,15)
print('N = ', N)

S = 0.0
for i in range(1,N+1):
x = 2 * i - 1
S += x
print(i," : ",x," : ",S)
print("Sum = ",S)