fork download
  1. #include <stdio.h>
  2. #include <math.h>
  3.  
  4. int main() {
  5. // Define the first term (a) and the common ratio (r)
  6. double a = 0.5;
  7. double r = 0.2;
  8.  
  9. // Print the first 100 terms of the geometric series
  10. printf("First 100 terms of the geometric series:\n");
  11. for (int i = 0; i < 100; i++) {
  12. // Calculate the nth term using the formula: a * r^(n-1)
  13. double term = a * pow(r, i);
  14. printf("Term %d: %lf\n", i + 1, term);
  15. }
  16.  
  17. return 0;
  18. }
Success #stdin #stdout 0.01s 5288KB
stdin
Standard input is empty
stdout
First 100 terms of the geometric series:
Term 1: 0.500000
Term 2: 0.100000
Term 3: 0.020000
Term 4: 0.004000
Term 5: 0.000800
Term 6: 0.000160
Term 7: 0.000032
Term 8: 0.000006
Term 9: 0.000001
Term 10: 0.000000
Term 11: 0.000000
Term 12: 0.000000
Term 13: 0.000000
Term 14: 0.000000
Term 15: 0.000000
Term 16: 0.000000
Term 17: 0.000000
Term 18: 0.000000
Term 19: 0.000000
Term 20: 0.000000
Term 21: 0.000000
Term 22: 0.000000
Term 23: 0.000000
Term 24: 0.000000
Term 25: 0.000000
Term 26: 0.000000
Term 27: 0.000000
Term 28: 0.000000
Term 29: 0.000000
Term 30: 0.000000
Term 31: 0.000000
Term 32: 0.000000
Term 33: 0.000000
Term 34: 0.000000
Term 35: 0.000000
Term 36: 0.000000
Term 37: 0.000000
Term 38: 0.000000
Term 39: 0.000000
Term 40: 0.000000
Term 41: 0.000000
Term 42: 0.000000
Term 43: 0.000000
Term 44: 0.000000
Term 45: 0.000000
Term 46: 0.000000
Term 47: 0.000000
Term 48: 0.000000
Term 49: 0.000000
Term 50: 0.000000
Term 51: 0.000000
Term 52: 0.000000
Term 53: 0.000000
Term 54: 0.000000
Term 55: 0.000000
Term 56: 0.000000
Term 57: 0.000000
Term 58: 0.000000
Term 59: 0.000000
Term 60: 0.000000
Term 61: 0.000000
Term 62: 0.000000
Term 63: 0.000000
Term 64: 0.000000
Term 65: 0.000000
Term 66: 0.000000
Term 67: 0.000000
Term 68: 0.000000
Term 69: 0.000000
Term 70: 0.000000
Term 71: 0.000000
Term 72: 0.000000
Term 73: 0.000000
Term 74: 0.000000
Term 75: 0.000000
Term 76: 0.000000
Term 77: 0.000000
Term 78: 0.000000
Term 79: 0.000000
Term 80: 0.000000
Term 81: 0.000000
Term 82: 0.000000
Term 83: 0.000000
Term 84: 0.000000
Term 85: 0.000000
Term 86: 0.000000
Term 87: 0.000000
Term 88: 0.000000
Term 89: 0.000000
Term 90: 0.000000
Term 91: 0.000000
Term 92: 0.000000
Term 93: 0.000000
Term 94: 0.000000
Term 95: 0.000000
Term 96: 0.000000
Term 97: 0.000000
Term 98: 0.000000
Term 99: 0.000000
Term 100: 0.000000