title: How to make sure that you return something in recursive functions?
body: <p>I am writing a simple GCD functions and I am sure that it will always return something as I have written a return statement in an if. How do I make sure that the program does not end in compilation error. Is it ok to write another return statement at the end?</p>
  
  <pre><code>private static int gcd(long a, long b){
    if(b==0) 
        return (int)a;
    else{
        a=a%b;
        gcd(b,a);
    }
    //I want to avoid the next statement as I think it is redundant, 
    //but the compiler does not allow me to skip it.
    return 0;
  }
  </code></pre>