#include<stdio.h> int main(){ float up=2.0,down=1.0; int n,i; int temp; float sum=0.0; scanf("%d",&n); for(i=1;i<=n;i++){ sum = sum + up/down; temp = up + down; down = up; up = temp; } printf("%.2f",sum); return 0; } |
Double click to view unformatted code.