All pastes #254002 Raw Edit

Anonymous

public c v1 · immutable
#254002 ·published 2006-11-21 10:46 UTC
rendered paste body
#include <stdio.h>#include <stdlib.h>#include "bint.h"bool fact ( bint *b, word n ){  word i;  bint_set( b, 1 );  for ( i = 1; i < n; i++ )    if ( !bint_mul( b, i + 1 ) )      return false;  return true;}int main ( int argc, char **argls ){  bint b;  dword i, n = 0;  if ( argc != 1 )    n = atoi( argls[1] );  if ( !n )    n = 95;  bint_create( &b, 1 );  bint_reserve( &b, 1024 );//  for ( i = 0; i < 32; i++ )//  {//    bint_mul( &b, 2 );//    bint_print( stdout, &b );//  }  if ( !fact( &b, n ) )  {    fputs( "out of memory\n", stderr );    bint_destroy( &b );    return 1;  }  if ( !bint_print( stdout, &b ) )    fputs( "out of memory\n", stderr );  bint_destroy( &b );  return 0;}