English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

ok my program is supposted to return the greatest common divisor of two inputted numbers (i and j), the numbers are already assigned to l(largest) and s (smallest), i need to make a class, so so far i have (for the class) (r = remainder) wehn the remainder is 0, then the smallest should be returned:
public int gcd(int l, int s, int i, int j)
{
int r = l % s;
if (r == 0)
return s;
else
gcd(s,r,i,j);

}

how can you do this without having the error of no return statement ( if the 'if' is not ran) thanks

2006-10-22 11:07:58 · 1 answers · asked by YahooAnswers 2 in Computers & Internet Programming & Design

Thanks so much anal pogrammer
ur the best answer

2006-10-22 11:19:09 · update #1

1 answers

Change the code to

else
return gcd(s,r,i,j);

That will do it.

2006-10-22 11:16:07 · answer #1 · answered by AnalProgrammer 7 · 1 0

fedest.com, questions and answers