6

Library of functions

  1. int fact( int n ) {
  2.     int f;
  3.  
  4.     if ( n < 0 )
  5.         return 0;
  6.  
  7.     for ( f = 1; n > 1; --n )
  8.         f *= n;
  9.  
  10.     return f;
  11. }
  1. #if !defined( _FACT_H )
  2. #define _FACT_H
  3.  
  4. int fact( int );
  5.  
  6. #endif
  1. #include "fact.h"
  2.  
  3. int perm( int n, int k ) {
  4.     int f;
  5.  
  6.     if ( n < 0 || k < 0 || k > n )
  7.         return 0;
  8.  
  9.     return fact(n)/fact(n-k);
  10. }
  1. #if !defined( _PERM_H )
  2. #define _PERM_H
  3.  
  4. int perm( int, int );
  5.  
  6. #endif

Comments

Your comment:
[p] [b] [i] [u] [s] [quote] [pre] [br] [code] [url] [email] strip help 2000

Enter a maximum of 2000 characters.
Improve the presentation of your text with the following formatting tags:
[p]paragraph[/p], [b]bold[/b], [i]italics[/i], [u]underline[/u], [s]strike[/s], [quote]citation[/quote], [pre]as is[/pre], [br]line break,
[url]http://www.izend.org[/url], [url=http://www.izend.org]site[/url], [email]izend@izend.org[/email], [email=izend@izend.org]izend[/email],
[code]command[/code], [code=language]source code in c, java, php, html, javascript, xml, css, sql, bash, dos, make, etc.[/code].