Advertisement
Guest User

Untitled

a guest
Aug 17th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.57 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <math.h>
  3.  
  4. void compute();
  5.  
  6. int main( int argc, char** argv ) {
  7.     compute();
  8.     return 0;
  9. }
  10.  
  11. void compute() {
  12.    float f1 = 0, f2 = 0, f3 = 0;
  13.    int i;
  14.    for( i = 1; i <= 1000; ++i ) {
  15.       f1 += pow( .9, i );
  16.    }
  17.    printf( "Suma postepu geometrycznego (od min do max sumowana): %f\n", f1 );
  18.    for( i = 1000; i != 0; --i ) {
  19.       f2 += pow( .9, i );
  20.    }
  21.    printf( "Suma postepu geometrycznego (od max do min sumowana): %f\n", f2 );
  22.    f3 = .9 * ( (1 - pow(0.9,1000)) / (1 - 0.9) );
  23.    printf( "Suma teoretyczna: %f\n", f3 );
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement