Using this idea makes my solution into
x = 0;
for( i = (n < N ? n : N) ; i > 0 ; --i )
x = (i * x + i) % n;
Dave
On Dec 8, 7:27 am, Ashim Kapoor <[email protected]> wrote:
> Let me try. Any thing involving n would leave no remainder.
>
> so (1 + 2 ! + ... + n ! + .... + N !) mod n = (1 + 2 ! + ... + (n-1)! ) mod
> n
>
> This should be computed from a loop. I don't know how to reduce it further.
>
> Ashim.
>
>
>
> On Wed, Dec 8, 2010 at 6:49 PM, ankit sablok <[email protected]> wrote:
> > Q) can anyboy find me the solution to this problem
>
> > Given an integer N and an another integer n we have to write a program
> > to find the remainder of the following problems
> > (1! + 2! + 3! + 4! + ..................... + N!)mod(n)
>
> > N<=1000000
> > n<=1000;
>
> > please help me write a program for this problem
> > thanx in advance
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Algorithm Geeks" group.
> > To post to this group, send email to [email protected].
> > To unsubscribe from this group, send email to
> > [email protected]<algogeeks%2bunsubscr...@googlegroups.com>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/algogeeks?hl=en.- Hide quoted text -
>
> - Show quoted text -
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.