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!!!

NCrom Good solution... [2] // Problem 1083. Factorials!!! 15 May 2004 20:26
#include <string.h>

unsigned long int fact(int n, int k){
   unsigned long int p=1;
   int i;
   i=n;
   while(i>0){
      p*=i;
      i=i-k;
      }
   return p;
   }

void main(){
   int n,k;
   cin>>n;
   char a[25];
   cin.getline(a,24,'\n');
   k=strlen(a)-1;
   cout<<fact(n,k);
   }
Md. Sohrab Mahmud Re: Good solution... [1] // Problem 1083. Factorials!!! 27 Jul 2007 12:01
Thanx. I got a lot helps....
Entheogen Re: Good solution... // Problem 1083. Factorials!!! 14 Nov 2007 07:44
long f( long n, long k )
{
    long a = n-k;
    if ( a <= 0 ){ return 1;}
    return a * f( a, k );
}