Thread: Finding Factorial of a large number using array

  1. #1
    Registered User
    Join Date
    Sep 2012
    Location
    Hyderabad, Andhra Pradesh, India
    Posts
    8

    Post Finding Factorial of a large number using array

    Q.There are multiple test cases.
    Each line contains a single integer n.
    Find factorial of n ( n<150)
    Input:
    6 (no. of test cases )
    25
    Output:
    720
    15511210043330985984000000


    Code:
     #include<stdio.h>
      int main()
      {
              int t,n,count=1,rem=0,k=0,i,count1,t1;
              int array[4000];
              scanf("%d",&t);
              for(count=1;count<=t;count++)
              {
                      scanf("%d",&n);
                      i=3999;
                      array[3999]=1;
                      for(count1=2;count1<=n;count1++)
                      {
                              for(i=3999;i>0;i--)
                              {
                                      t1=(array[i]*count1)+rem;
                                      rem=0;
                                      if(t2>9)
                                      {
                                              array[i]=t1%10;
                                              rem=t1/10;
                                              k++;
                                      }
                                      else
                                      {
                                              array[i]=t1;
                                              k++;
                                      }
                              }
                              t1=0;
                              rem=0;
                      }
                      for(i=3975;i<4000;i++)
                      {
                              printf("%d",array[i]);
                      }
                      printf("\n");
              }
             return 0;

  2. #2
    Registered User
    Join Date
    Jun 2005
    Posts
    6,815
    Being a member of an internet forum does not endow anyone with mindreading skills.

    How may we help you with YOUR problem, about which you have given no pertinent information?

    Before you answer my question, I suggest you read this link.
    Right 98% of the time, and don't care about the other 3%.

    If I seem grumpy or unhelpful in reply to you, or tell you you need to demonstrate more effort before you can expect help, it is likely you deserve it. Suck it up, Buttercup, and read this, this, and this before posting again.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. problem with large number factorial calculation
    By afr_c2011 in forum C++ Programming
    Replies: 2
    Last Post: 01-29-2011, 10:49 AM
  2. Replies: 8
    Last Post: 08-15-2010, 05:59 PM
  3. Finding largest number in array
    By el_chupacabra in forum C Programming
    Replies: 2
    Last Post: 01-22-2009, 02:31 PM
  4. Finding a repeating number in an array?
    By kabuatama in forum C Programming
    Replies: 7
    Last Post: 03-08-2006, 03:25 PM
  5. finding the element number in an array
    By tommy69 in forum C Programming
    Replies: 7
    Last Post: 04-02-2004, 04:26 AM

Tags for this Thread