It looks from the example like you pick the largest (as if the digits
were a binary number).  Here's what I get:

#include <stdio.h>

unsigned f(unsigned n, unsigned fi, unsigned fim1)
{
  if (fi > n) return n;
  unsigned r = f(n, fi + fim1, fi);
  if (r >= fi) {
    putchar('1');
    return r - fi;
  }
  putchar('0');
  return r;
}

int main(int argc, char *argv[])
{
  unsigned n;
  if (argc > 1 && sscanf(argv[1], "%u", &n) == 1) {
    f(n, 1, 1);
    putchar('\n');
  }
  return 0;
}

On Mar 17, 2:08 pm, Ravi Ranjan <ravi.cool2...@gmail.com> wrote:
> @ if for a given number more than 1 answer exist then whats the answer???

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to