Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- double sum_of_30_terms()
- {
- int i, count=0;
- double sum=0.0;
- for(i=1; count < 30; i *= 2)
- {
- count++;
- sum += 1.0 / i;
- }
- return sum;
- }
- int main()
- {
- cout << "Sum of 30 terms= " << sum_of_30_terms();
- return 0;
- }
Add Comment
Please, Sign In to add comment