Sum of the series 0.6, 0.06, 0.006, 0.0006, …to n terms
Given the number of terms i.e. n. Find the sum of the series 0.6, 0.06, 0.006, 0.0006, …to n terms.
Examples:
Input : 2 Output : 0.65934 Input : 3 Output : 0.665334
Lets denote the sum by S:
Using the formula
, we have [since r<1]

![]()
![]()
Hence the required sum is ![]()
Below is the implementation:
C++
// CPP program to find sum of 0.6, 0.06, // 0.006, 0.0006, ...to n terms #include <bits/stdc++.h> using namespace std; // function which return the // the sum of series float sumOfSeries(int n) { return (0.666) * (1 - 1 / pow(10, n)); } // Driver code int main() { int n = 2; cout << sumOfSeries(n); } |
chevron_right
filter_none
Java
// java program to find sum of 0.6, 0.06, // 0.006, 0.0006, ...to n terms import java.io.*; class GFG { // function which return the // the sum of series static double sumOfSeries(int n) { return (0.666) * (1 - 1 /Math. pow(10, n)); } // Driver code public static void main (String[] args) { int n = 2; System.out.println ( sumOfSeries(n)); } } // This code is contributed by vt_m |
chevron_right
filter_none
Python3
# Python3 program to find # sum of 0.6, 0.06, 0.006, # 0.0006, ...to n terms import math # function which return # the sum of series def sumOfSeries(n): return ((0.666) * (1 - 1 / pow(10, n))); # Driver code n = 2; print(sumOfSeries(n)); # This code is contributed by mits |
chevron_right
filter_none
C#
// C# program to find sum of 0.6, 0.06, // 0.006, 0.0006, ...to n terms using System; class GFG { // function which return the // the sum of series static double sumOfSeries(int n) { return (0.666) * (1 - 1 /Math. Pow(10, n)); } // Driver code public static void Main () { int n = 2; Console.WriteLine( sumOfSeries(n)); } } // This code is contributed by vt_m |
chevron_right
filter_none
PHP
<?php // PHP program to find sum of 0.6, 0.06, // 0.006, 0.0006, ...to n terms // function which return the // the sum of series function sumOfSeries($n) { return (0.666) * (1 - 1 / pow(10, $n)); } // Driver code $n = 2; echo(sumOfSeries($n)); // This code is contributed by Ajit. ?> |
chevron_right
filter_none
Output:
0.65934
Recommended Posts:
- Find n terms of Fibonacci type series with given first two terms
- Sum of the first N terms of the series 5,12, 23, 38....
- Sum of the series 5+55+555+.. up to n terms
- Sum of the first N terms of the series 2,10, 30, 68,....
- Sum of first n terms of a given series 3, 6, 11, .....
- Sum of the first N terms of the series 2, 6, 12, 20, 30....
- Sum of the series (1*2) + (2*3) + (3*4) + ...... upto n terms
- Find the sum of first N terms of the series 2×3 + 4×4 + 6×5 + 8×6 + ...
- 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
- Find the sum of n terms of the series 1,8,27,64 ....
- 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, ...
- Sum of the series 0.7, 0.77, 0.777, ... upto n terms
- Find the sum of series 0.X + 0.XX + 0.XXX +... upto k terms
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.


