You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+3-2Lines changed: 3 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,5 @@
1
1
# 196-algorithm
2
-
Implementation of the 196-algorithm to find palindromes in a predetermined sequence of instructions.
2
+
Implementation of the 196-algorithm to find palindromes in a number sequence.
3
3
4
4
Inspired by https://www.youtube.com/watch?v=bN8PE3eljdA&t=374s
5
5
@@ -13,14 +13,15 @@ g++ main.cpp -o main
13
13
./main
14
14
```
15
15
## Approach
16
-
Given a number n we iteratively reassign n as the sum of previous n and the reverse of previous n until n is a palindrome.
16
+
Given a number n we iteratively reassign to n the sum of n and the reverse of n until n is a palindrome.
17
17
18
18
Example Given:
19
19
```
20
20
n = 19 // no palindrome, iteration = 0
21
21
n = 19 + 91 = 110 // no palindrome, iteration = 1
22
22
n = 110 + 11 = 121 // palindrome, iteration = 2
23
23
```
24
+
Note, that n is of type int. This can result in exceeding the allocated storage size for larger n or higher iterations. To prevent you can set the datatype to long or a much larger datatype.
0 commit comments