A simple recursive bruteforce algorithm in C