![]() |
Given a number n, find sum of square of first n odd natural numbers. Examples : Input : 3 Output : 35 12 + 32 + 52 = 35 Input : 8 Output : 680 12 + 32 + 52 + 72 + 92 + 112 + 132 + 152 A simple solution is to traverse through n odd numbers and find the sum of square. Below is the implementation of the approach. C++
Javascript
Javascript
Output : 680 Time Complexity: O(1), the code will run in a constant time. |
Reffered: https://www.geeksforgeeks.org
Mathematical |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 15 |