Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
stacked26787ypublic int gcd( int a, int b ) {
if ( a < 0 )
return gcd( -1 * a, b );
if ( b < 0 )
return gcd( a, -1 * b );
if ( a > b )
return gcd( a - b, b );
if ( a < b )
return gcd( a, b - a );
return a;
}
public boolean even( int num ) {
if ( gcd( num, 2 ) == 2 )
return true;
else
return false;
} -
Navigatr9377yI'm so confused as to what this code is even supposed to do. Is it trying to determine whether or not an integer is an even number? :S
-
Navigatr9377y@DefiniteGoose Couldn't you just:
public bool even(int number) {
return (number % 2 == 0);
}
(Note: I'm not familiar with Java, which is what I assume this is.) -
sallai2047y@inaba Thanks! I've seen it a lot of times but never actually found out what it's called :)
++'d
</offtopic>
Related Rants
-
l0om44100% Real. And it's not even the worst on the site.
-
Codazed11Being 100% serious, I saw a guy in my Computer Programming I class using MS Word to write code that he would c...
-
dfox8I worked with a good dev at one of my previous jobs, but one of his faults was that he was a bit scattered and...
public boolean even( int num ) {
if ( num < 0 )
num = -1 * num;
while ( num > 1 )
num = num - 2;
if ( num == 0 )
return true;
else
return false;
}
rant
wk99