We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 45f81ad commit feff19aCopy full SHA for feff19a
lcof/面试题64. 求1+2+…+n/Solution.cpp
@@ -0,0 +1,9 @@
1
+class Solution
2
+{
3
+public:
4
+ int sumNums(int n)
5
+ {
6
+ n && (n += sumNums(n - 1));
7
+ return n;
8
+ }
9
+};
lcof/面试题64. 求1+2+…+n/Solution.rs
@@ -0,0 +1,6 @@
+impl Solution {
+ pub fn sum_nums(mut n: i32) -> i32 {
+ n!=0&&(n+=Solution::sum_nums(n-1),true).1;
+ n
+}
lcof/面试题64. 求1+2+…+n/Solution.ts
@@ -0,0 +1,3 @@
+var sumNums = function (n: number): number {
+ return n && n + sumNums(n - 1);
0 commit comments