summaryrefslogtreecommitdiff
path: root/1553/CH7/EX7.12/7Ex12.sce
diff options
context:
space:
mode:
Diffstat (limited to '1553/CH7/EX7.12/7Ex12.sce')
-rw-r--r--1553/CH7/EX7.12/7Ex12.sce22
1 files changed, 22 insertions, 0 deletions
diff --git a/1553/CH7/EX7.12/7Ex12.sce b/1553/CH7/EX7.12/7Ex12.sce
new file mode 100644
index 000000000..1e8eeddad
--- /dev/null
+++ b/1553/CH7/EX7.12/7Ex12.sce
@@ -0,0 +1,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