Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Challenge: fastest program wins

Name: Anonymous 2009-04-14 12:59

Write a program in your language that
1.opens a file as arbitrary precision integer.
2.divides the number by 3.
3.stores the binary result in another file.

Name: Anonymous 2009-04-15 1:36

>>22
try this one.
#include <stdio.h>
#include <gmp.h>

int main(int argc, char **argv)
{ if(argc > 2)
  { FILE *f;
    mpz_t n;
    mpz_init(n);
    if(f = fopen(argv[1], "r"))
    { mpz_inp_str(n, f, 10);
      fclose(f);
      mpz_tdiv_q_ui(n, n, 3);
      if(f = fopen(argv[2], "w"))
      { mpz_out_str(f, 10, n);
        fputs("\n", f);
        fclose(f); }
      mpz_clear(n); }}
  return 0; }

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List