#include <stdio.h> #include <stdlib.h> /* run this program using the console pauser or add your own getch, system("pause") or input loop */ int main(int argc, char *argv[]) { int n; double t=0, i,a=2,b=1,q; scanf("%d",&n); for(i=1;i<=n;i++) {t+=a/b; q=a; a=a+b; b=q; } printf("%f",t); return 0; } |
Double click to view unformatted code.