Skip to content

Commit 6e85698

Browse files
committed
add digits
1 parent e6a0501 commit 6e85698

File tree

1 file changed

+14
-43
lines changed

1 file changed

+14
-43
lines changed

README.md

Lines changed: 14 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,14 @@
11
# `Today Update`
22
## Math
3-
### 9 Palindrome Number
4-
* [Github:#9 Palindrome Number](/Math/Math.Lib/IssPalindromeSln.cs)
5-
* [CSDN:#9 Palindrome Number](http://blog.csdn.net/daigualu/article/details/72717009)
6-
```C#
7-
public bool IsPalindrome(int x)
8-
{
9-
int palindromex = 0, tmp = x;
10-
int sumbit = 0;
11-
//calcuate bit count
12-
while (tmp > 0)
13-
{
14-
sumbit++;
15-
tmp /= 10;
16-
}
17-
tmp = x;
18-
//get a number reversely
19-
while (tmp > 0)
20-
{
21-
//if palindromex happens overflow, it would return false;
22-
palindromex += tmp % 10 * (int)System.Math.Pow(10, --sumbit);
23-
tmp /= 10;
24-
}
25-
return palindromex == x;
26-
}
27-
```
3+
### 258 Add Digits
4+
* [Github:#258 Add Digits](/Math/Math.Lib/AddDigitsSln.cs)
5+
* [CSDN:#258 Add Digits](http://blog.csdn.net/daigualu/article/details/72724479)
6+
* Tips:
7+
* https://en.wikipedia.org/wiki/Digital_root#Congruence_formula
8+
* https://en.wikipedia.org/wiki/Vedic_square
9+
* In Indian mathematics, a Vedic square is a variation on a typical 9 × 9 multiplication table where the entry in each cell is the digital root of the product of the column and row headings i.e. the remainder when the product of the row and column headings is divided by 9 (with remainder 0 represented by 9). Numerous geometric patterns and symmetries can be observed in a Vedic square some of which can be found in traditional Islamic art.
10+
![VedicSquare](/Math/Math.Lib/VedicSquare.png)
2811

29-
### 171 Excel Sheet Column Number
30-
* [Github:#171 Excel Sheet Column Number](/Math/Math.Lib/ExcelColumnNumberSln.cs)
31-
* [CSDN:#171 Excel Sheet Column Number](http://blog.csdn.net/daigualu/article/details/72717145)
32-
```C#
33-
public int TitleToNumber(string s)
34-
{
35-
char[] chs= {'A','B','C','D','E','F','G','H','I','J','K',
36-
'L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
37-
Dictionary<char,int> dict = new Dictionary<char,int>();
38-
for(int i=0; i<chs.Length;i++) dict.Add(chs[i],i+1);
39-
int scnt = s.Length, rtnsum=0;
40-
for (int i = scnt - 1,j=0; i >= 0; i--,j++)
41-
rtnsum += dict[s[i]] * (int)System.Math.Pow(26, j);
42-
return rtnsum;
43-
}
44-
45-
```
4612
---
4713
---
4814

@@ -226,7 +192,12 @@ Tags are following:
226192
* [CSDN:#69 Sqrt(x)](http://blog.csdn.net/daigualu/article/details/72578272)
227193
* Tips:
228194
* careful to prevent overflowing! Again careful to **overflow**!
229-
195+
### 9 Palindrome Number
196+
* [Github:#9 Palindrome Number](/Math/Math.Lib/IssPalindromeSln.cs)
197+
* [CSDN:#9 Palindrome Number](http://blog.csdn.net/daigualu/article/details/72717009)
198+
### 171 Excel Sheet Column Number
199+
* [Github:#171 Excel Sheet Column Number](/Math/Math.Lib/ExcelColumnNumberSln.cs)
200+
* [CSDN:#171 Excel Sheet Column Number](http://blog.csdn.net/daigualu/article/details/72717145)
230201
## Two Pointers
231202
* [#345 Reverse Vowels of a String](http://blog.csdn.net/daigualu/article/details/69257693)
232203

0 commit comments

Comments
 (0)