Skip to content

Commit 014a404

Browse files
committed
Commited
1 parent 212d0ad commit 014a404

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

Leetcode/ClumsyFactorial.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
class Solution {
2+
public:
3+
int clumsy(int N) {
4+
if(N==1)
5+
return 1;
6+
if(N == 2)
7+
return 2;
8+
if(N == 3)
9+
return 6;
10+
if(N == 4)
11+
return 7;
12+
13+
if(N%4 == 0)
14+
return N+1;
15+
if(N%4 == 3)
16+
return N-1;
17+
18+
return N+2;
19+
20+
}
21+
};

0 commit comments

Comments
 (0)