We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 03cebf3 commit e2d0139Copy full SHA for e2d0139
first_last_same_digits.js
@@ -0,0 +1,18 @@
1
+// Given a range of numbers, count the numbers which have same first and last digits
2
+// Ex: Between 7 and 20 such numbersare 8,9 and 11
3
+let firstDigit = 0
4
+let lastDigit = 0
5
+
6
+for (let i = 8; i < 20; i++) {
7
+ if (i < 10) {
8
+ firstDigit = i
9
+ lastDigit = i
10
+ } else {
11
+ firstDigit = Math.floor(i / 10)
12
+ lastDigit = i % 10
13
+ }
14
15
+ if (firstDigit === lastDigit) {
16
+ console.log(i)
17
18
+}
0 commit comments