Вычислить через while (x-2)(x-4)(x-8)(x-64) /(x-1)(x-3)(x-7)(x-63) - C (СИ)

Узнай цену своей работы

Формулировка задачи:

в чем ошибка?
#include <stdio.h>
#include <conio.h>
 
void main()
{
   int a,i,x,ch,nch,prz;
   double vse,raz;
   printf("Enter x: ");
    scanf("%d",&x);
    prz=1; vse=1; nch=0; raz=0;ch=2;
   while(i<=5)
   {
     prz=prz*ch; //prz=ch=2
     if(i=5) prz=prz*4;
     nch=prz-1;  
     raz=(x-prz)/(x-nch);
     vse=vse*raz; i++;
   }//while
   printf("Answer= %d ",vse);
 
   getch();
}

Решение задачи: «Вычислить через while (x-2)(x-4)(x-8)(x-64) /(x-1)(x-3)(x-7)(x-63)»

textual
Листинг программы
#include <stdio.h>
#include <conio.h>
 
int main()
{
    int i = 1, x;
    double num = 1., den = 1., pow = 1.; // num - числитель, den- знаменатель
    scanf("%d", &x);
    
    while (i <= 4)
    {
        if (i == 4) pow *= 8;
        else pow *= 2.;
        if (x == pow - 1.) 
        {
            printf("Answer: Infinity");
            return 0;
        }
        else if (x == pow)
        {
            printf("Answer: 0");
            return 0;
        }
        else
        {
            num *= (double)(x - pow);
            den *= (double)(x - pow + 1.);
        }
        i++;
    }
    printf("Answer: %.4f", num/den);
    getch();    
 
    return 0;
}

Оцени полезность:

8   голосов , оценка 4 из 5
Похожие ответы