[ create a new paste ] login | about

Link: http://codepad.org/c68p2u7N    [ raw code | output | fork ]

C, pasted on Jul 10:
#include <stdio.h>

char mem[0x10000];

int main(void) {
  char a = 50;
  short hl;

  mem[0x0100] = 0;
  mem[0x0101] = 1;
  hl = 0x0101;

writefibs:
  ++hl;
  mem[hl] = mem[hl-1] + mem[hl-2];
  if (mem[hl] <= a) goto writefibs;
  
revfind:
  if (a == 0) return 0;
  if (mem[hl] <= a) goto found;
  hl--;
  goto revfind;

found:
  printf("%d\n", mem[hl]);
  a -= mem[hl];
  goto revfind;
}


Output:
1
2
3
34
13
3


Create a new paste based on this one


Comments: