We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 3a84536 commit a9bd8a4Copy full SHA for a9bd8a4
lcof/面试题64. 求1+2+…+n/README.md
@@ -147,6 +147,18 @@ public class Solution {
147
}
148
```
149
150
+#### Swift
151
+
152
+```swift
153
+class Solution {
154
+ func sumNums(_ n: Int) -> Int {
155
+ var s = n
156
+ let _ = n > 0 && { s += sumNums(n - 1); return true }()
157
+ return s
158
+ }
159
+}
160
+```
161
162
<!-- tabs:end -->
163
164
<!-- solution:end -->
lcof/面试题64. 求1+2+…+n/Solution.swift
@@ -0,0 +1,7 @@
1
2
3
4
5
6
7
0 commit comments