1 / 2
Dec 2008

include

#include <stdlib.h>

int main(void)
{
    int n,i;
    scanf("%d",&n);
   
    int *list;
    list=(int*)malloc(n*sizeof(int));
   
    double a;
    for(i=0;i<n;i++)  scanf("%d",&list[i]);
   
    for(i=0;i<n;i++)
    {
        if(list[i]==0)
        printf("1\n");
        else
        {
            a=list[i];
            
            while(list[i]>1)
            {
                a=a*(list[i]-1),
                list[i]--;
            }
            printf("%1.f\n",a);
        }
    }
    system("pause"); 
    return 0;
}

I need help in order to solve this problem do not know why I said wrong answer

  • created

    Dec '08
  • last reply

    Dec '08
  • 1

    reply

  • 123

    views

  • 2

    users

If you try the largest possible input you'll see a double isn't precise enough.

Suggested Topics

Topic Category Replies Views Activity
C and C++ 0 34 26d

Want to read more? Browse other topics in C and C++ or view latest topics.