View Code of Problem 48

#include<stdio.h>

int main(){
          double sum = 0;
          int n;
          double a = 2;
          double b = 1;
          double temp;
          int i ;
          printf("请输入正整数n,1<=n<=10:");
          scanf("%d",&n);   
          for(i=1;i<=n;i++){
                  
                  sum = sum + a/b;
            
                  temp = b;
                  b = a;
                  a = a + temp;
          }
          printf("%.6lf",sum);
          return 0 ;
  } 

Double click to view unformatted code.


Back to problem 48