View Code of Problem 72

#include<stdio.h>
void main()
{
    int i, m;
    double h,s, n, w;
    scanf("%lf %d",&n, &m);
    h = n;
    s = n;
    for(i=1;i<=m;i++)
    {
        w = h;
        h = h * 0.5;
        if(i==1)
            continue;

        s = w*2 + s;
    }
    printf("%.2lf %.2lf\n",h,s);
}

Double click to view unformatted code.


Back to problem 72