factorial of 1000

Mar 29, 2015 at 5:50am
please help me finding the factorial of 1000 using doubly linked list in c++
Mar 29, 2015 at 6:18am
Could you post what you're working with, then explain what part you're having trouble with?
Mar 29, 2015 at 6:27am
I am unable to initiate it ... I can't understand what to do ... actually I have to complete this by today so feeling some depressed
Mar 29, 2015 at 6:28am
I'm not certain how you'd like us to help you. We can't do it for you; you need to at least attempt something.
Mar 29, 2015 at 6:31am
Please provide me ready code for atleast multiplication of two numbers using doubly linked list ...
Mar 29, 2015 at 6:41am
We aren't going to do you work for you. If you aren't willing to put forth any effort, why should I?
Mar 29, 2015 at 8:20am
Dont leave things to the last second buddy, Shit doesnt end well.

Edit: What butthurt person reported me? I bet its someone who leaves shit to last second and gets it up the butt.
Last edited on Mar 29, 2015 at 2:44pm
Mar 29, 2015 at 2:01pm
Please provide me ready code for atleast multiplication of two numbers using doubly linked list ...

When I read this, it's like you're asking "please tell me how to make a cup of coffee using a deck of cards." I don't see the connection between the linked list and multiplying numbers. Can you post more information on the assignment, particularly what the linked list ha to do with it. Is it supposed to represent the numbers some how?
Mar 29, 2015 at 6:05pm
closed account (D80DSL3A)
@dhayden. Big integers can be represented in a container by making each element represent 1 or more digits of the big number.
See http://www.cplusplus.com/forum/lounge/32041/ for several examples of bigInt classes built on an underlying std::vector container, etc.
Using a linked list is somewhat reasonable (maybe even good) as the arithmetic operations are carried out digit by digit by iterating over the elements.

@dinesh9293
You don't need to write a bigInt*bigInt function for this problem.
A simpler bigInt *= int will do.
The simplest way I've found to approach your specific problem is to allow each node to store 4 digits of the number, so base = 10,000.

If storing the least significant digits in the head node, then:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// implement multiplication using the usual "by hand" method
dlist& operator*=( dlist& A, int f )
{
    f %= base;// allowing only a factor smaller than base
    int product = 0;
    int carry = 0;
    dnode* it = A.head;

    while( it )
    {
        product = it->x * f + carry;
        it->x = product%base;
        carry = product/base;
        it = it->next;
    }

    if( carry ) A.push_back( carry );

    return A;
}
Mar 30, 2015 at 6:12am
thanks bro i have completed
Topic archived. No new replies allowed.