blob: 1e8eeddad079b95e8f46b28dd89d8d48b0f02086 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
//Chapter 7 Ex12
clc;
close;
//let ten's digit be x, thus unit's digit is 9-x
//number=10x+9-x=9x+9
//number obtained by reversing digits=10(9-x)+x=90-9x
//polynomial is: 18x-144=0
mycoeff=[-144 18];
p=poly(mycoeff,"x","coeff");
ans=9*roots(p)+9; //since given number as calculated in line 6
printf("The number is: %d",ans);
//Alternative logic for same problem
for x=1:99
if((18*x-144)==0)
num=(9*x+9);
printf("\n Alternate logic: \n The number is: %d",num);
break;
end
end
|