working f, except for max 0
Got it working, but apparently it segfaults on some test cases
Added stuff to Makefile