Find sum of the series ?3 + ?12 +……… upto N terms
Given a number n, the task is to find the sum of first n terms of this series. Below is the series:
![]()
Examples:
Input: n = 10 Output: 95.2628 Input: n = 5 Output: 25.9808
This series can be seen as-
![Rendered by QuickLaTeX.com $$1\sqrt{3}+2\sqrt{3}+3\sqrt{3}+4\sqrt{3}+5\sqrt{3}+\cdots$$ Now, take $\sqrt{3} $ as common, we get- $$\sqrt{3}\left[1+2+3+4+5+\cdots\right]$$ $$sum=\sqrt{3}*\left(\frac{n*(n+1)}{2}\right)$$](https://web.archive.org/web/20190916080627im_/https://www.geeksforgeeks.org/wp-content/ql-cache/quicklatex.com-cfce461b13293a27d43b8c3ac5ed5b60_l3.png)
Below is the required implementation:
C++
// C++ implementation of above approach #include <bits/stdc++.h> #define ll long long int using namespace std; // Function to find the sum double findSum(ll n) { // Apply AP formula return sqrt(3) * (n * (n + 1) / 2); } // Driver code int main() { // number of terms ll n = 10; cout << findSum(n) << endl; return 0; } |
chevron_right
filter_none
Java
// Java implementation of // above approach import java.io.*; class GFG { // Function to find the sum static double findSum(long n) { // Apply AP formula return Math.sqrt(3) * (n * (n + 1) / 2); } // Driver code public static void main (String[] args) { // number of terms long n = 10; System.out.println( findSum(n)); } } // This code is contributed // by inder_verma.. |
chevron_right
filter_none
Python3
# Python3 implementation of above approach #Function to find the sum import math def findSum(n): # Apply AP formula return math.sqrt(3) * (n * (n + 1) / 2) # Driver code # number of terms if __name__=='__main__': n = 10 print(findSum(n)) # This code is contributed by sahilshelangia |
chevron_right
filter_none
C#
// C# implementation of // above approach using System; class GFG { // Function to find the sum static double findSum(long n) { // Apply AP formula return Math.Sqrt(3) * (n * (n + 1) / 2); } // Driver code public static void Main () { // number of terms long n = 10; Console.WriteLine( findSum(n)); } } // This code is contributed // by inder_verma.. |
chevron_right
filter_none
PHP
<?php // PHP implementation of above approach // Function to find the sum function findSum($n) { // Apply AP formula return sqrt(3) * ($n * ($n + 1) / 2); } // Driver code // number of terms $n = 10; echo findSum($n); // This code is contributed // by inder_verma ?> |
chevron_right
filter_none
Output:
95.2628
Recommended Posts:
- Find Sum of Series 1^2 - 2^2 + 3^2 - 4^2 ..... upto n terms
- Find the sum of series 3, -6, 12, -24 . . . upto N terms
- Find the sum of series 0.X + 0.XX + 0.XXX +... upto k terms
- Find the sum of the series 1+11+111+1111+..... upto n terms
- Find sum of the series 1+22+333+4444+...... upto n terms
- Program to find the sum of the series 23+ 45+ 75+..... upto N terms
- Sum of the series 1 / 1 + (1 + 2) / (1 * 2) + (1 + 2 + 3) / (1 * 2 * 3) + - - - - - - upto n terms.
- Sum of series 2/3 - 4/5 + 6/7 - 8/9 + ------- upto n terms
- Sum of the series 0.7, 0.77, 0.777, ... upto n terms
- Sum of the series (1*2) + (2*3) + (3*4) + ...... upto n terms
- Find n terms of Fibonacci type series with given first two terms
- Find the sum of first N terms of the series 2×3 + 4×4 + 6×5 + 8×6 + ...
- Find the sum of all the terms in the n-th row of the given series
- Find the sum of first N terms of the series 2*3*5, 3*5*7, 4*7*9, ...
- Find the sum of n terms of the series 1,8,27,64 ....
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



