ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1083. Factorials!!!

Should we multiply by k or n%k if (n - i*k) equals k or n%k ?
Posted by Simoren 21 Aug 2014 20:08
Hello,
Should we multiply by k or n%k if (n - i*k) equals k or n%k ?
Which sample is correct?
Sample 1
8!! = 8 *(8-2)*(8-4)*(8-6)*2

Sample 2
8!! = 8 *(8-2)*(8-4)*(8-6)
Re: Should we multiply by k or n%k if (n - i*k) equals k or n%k ?
Posted by DocTor 12 Nov 2014 16:47
Sample 2 is correct
Re: Should we multiply by k or n%k if (n - i*k) equals k or n%k ?
Posted by Aman 5 Apr 2017 22:28
N! = 1 x 2 x 3 x 4....x (N-2) x (N-1) x N
N! = (N-1)! x N
factorial(N) = factorial(N-1) x N
We can calculate factorial of a number using recursion using above formulae.
http://www.techcrashcourse.com/2014/10/c-program-find-factorial-of-number.html
http://www.techcrashcourse.com/2015/03/c-program-to-find-factorial-of-number-using-recursion.html
Hope it helps.