Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <math.h>
- void compute();
- int main( int argc, char** argv ) {
- compute();
- return 0;
- }
- void compute() {
- float f1 = 0, f2 = 0, f3 = 0;
- int i;
- for( i = 1; i <= 1000; ++i ) {
- f1 += pow( .9, i );
- }
- printf( "Suma postepu geometrycznego (od min do max sumowana): %f\n", f1 );
- for( i = 1000; i != 0; --i ) {
- f2 += pow( .9, i );
- }
- printf( "Suma postepu geometrycznego (od max do min sumowana): %f\n", f2 );
- f3 = .9 * ( (1 - pow(0.9,1000)) / (1 - 0.9) );
- printf( "Suma teoretyczna: %f\n", f3 );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement