Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit e8cfc26

Browse files
committed
Update: Excel Sheet Column Title
1 parent d35c46b commit e8cfc26

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package excel_sheet_column_title
22

33
func convertToTitle(n int) string {
4-
if n<27 {
5-
return string(n -1+ 'A')
4+
if n--; n<26 {
5+
return string(n + 'A')
66
}
7-
return convertToTitle((n-1)/26) + string((n-1)%26+'A')
7+
return convertToTitle(n/26) + string(n%26+'A')
88
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /