Can anyone help me in a project i'm working,

Two doubts:

1 ) i need to do a function like, int sum(int x, int y), that return the sum of digits in representation of n in base b.

2 ) I need to do a function like int prime(int x), wich return 1 if int x is prime, or 0 if int x is not prime.

thank u very much