That's not actually (even close to) right (sorry) I don't know what I was thinking last night...
The last digit is the same if the two numbers are equal mod 10.
The last two digits are the same if the numbers are equal mod100
The last 3 digits are equal if the numbers are equal mod1000
.
.
The last n digits are equal if the numbers are equal mod 10^(n-1)
I think is what i meant, but that is still not entirely right
I think that it should've been
-
found=false;
-
if( this_number.number_of_digits=last_number.number_of _digits)
-
{
-
n=10;
-
while(!found && n<thisnumber)
-
{
-
int difference =this_number-last_number;
-
if ((abs(difference)mod n ==0)&&fifference/n <10)
-
{
-
found =true;
-
}
-
n=n*10;
-
}
-
return found;
-
}
-
Obviously you also need to check that this is true for the last number and first number