A small style tip

bearophile bearophileHUGS at lycos.com
Sun Jan 1 15:20:39 PST 2012


Mail Mantis:

> private int find_pos_divisor( int first, int second ) {
>     int temp;
>     while( second ) {
>         temp = second;
>         second = first % second;
>         first = temp;
>     }
>     return abs( first );
> } unittest {
>     assert( find_pos_divisor ( 10, 20 ) == 10 );
>     assert( find_pos_divisor ( 10, 0 ) == 10 );
>     assert( find_pos_divisor ( 9, 6 ) == 3 );
>     assert( find_pos_divisor ( 10, 3 ) == 1 );
> }

It's an interesting idea, I will try it.

Bye,
bearophile


More information about the Digitalmars-d mailing list