Треугольник Паскаля


/*///////////////////////////////////////////////////////////////

 Треугольник Паскаля, GNU C++, 2011-01-27
 
 Artix, master@7masterov.ru, icq:53666599, skype:artixmaster
 
 * Error in code? Nothing is perfect!
 * Free source for free Linux, use it for free!
 * Please, do not remove this comment!

///////////////////////////////////////////////////////////////*/

#include <stdio.h>
#include <string.h>

// Факториал x!
long fact(long x)
{
    if (x<=1) return 1;
    else return x*fact(x-1);
}

// Биноминальный коэффициент Ньютона C(n/k)
long bink(long n, long k)
{
    return 1.*fact(n)/fact(k)/fact(n-k);
}

int main()
{
    const int N=7;
    for(int i=0;i<=N;i++) {
        for(int m=0;m<(N-i)*4;m++) printf(" ");
        for(int j=0;j<=i;j++) {
            printf("  %04ld  ", bink(i,j));
        }
        printf("\n");
    }
    return 1;
}
// eof