![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
C Programming for sum of the series 0.6, 0.06, 0.006, 0.0006, …to n terms
The given series 0.6,0 .o6,.... is a geometric progression where each element is the previous element divided by 10. So find the sum of the series we have to apply the sum of GP one formula for r less than 1(r=0.1 in our case).
Sum = 6/10 [1- (1/10)n/(1-1/10)] Sum = 6/9 [1- (1/10)n] Sum = 2/3[1- (1/10n)]
Example
#include <stdio.h> #include <math.h> int main() { int n = 6; float sum = 2*((1 - 1 / pow(10, n)))/3; printf("sum = %f", sum); }
Output
sum = 0.666666
Advertisements