It is 997.
Chat with our AI personalities
63
#include<stdio.h> #include<conio.h> main() { int n,max=0,rem; printf("\n enter a number"); scanf("%d",&n); while(n!=0) { rem=n%10; n=n/10; if(rem>max) { max=rem: }} printf("\n the largest digit is: %d",max); getch(); }
int max = a>b?a:b; // set max to the larger of a and b
it was invented in 1950 when a Australian man Max Carter invented it because he wanted to make sense with direct numbers
Leaving aside the brute force method of trying all the number, The following is one way of reducing the number of possible solutions. You can elect, at any stage, to quit this process and try out each of the remaining possibilities. Max's number is odd. so it must be one of 43, 45, 47, 49, 51, 53, 57, 59, 61, 63. The difference between the digits is the same as the units digit which is odd. If the tens digit is 5, then the difference between 5 and the odd units digit would be even. That means the tens digit cannot be 5. Which leaves the following as possible solutions: 43, 45, 47, 49, 61, 63. Now, the tens digit is 4 or 6. The units digit must be between 1 and 9 (it is odd). so the difference between the tens and units digit must be 5 or fewer ie not 7 or 9. Then, since the difference is the same as the units digit, the units digit cannot be 7 or 9. So that leaves 43, 45, 61, 63. Now 43 an 45 both result in a difference of 1, not the units digit so neither can be a solution. That leaves 61 and 63. 61 has a digital difference of 5, not the units vaue which is 1. So 1 is not a possible answer and that leaves only 63. 6-3 = 3 so the difference is the same as the units digit. And that, my friend, is the answer - at long last!