+ 1
Write a program to print the sum of first thirty odd numbers?
3 Answers
+ 1
In Python
print(30*30)
0
int result = 0;
for(int i = 1; i < 60; i+=2)
{result += i;}
std::cout << result;
0
print((59+1)*15)
it is Gauss
1 + 59 +
3 + 57 +
....
in general
print((i_th odd +1) *(i_th odd + 1) /2)