File tree 3 files changed +24
-1
lines changed
3 files changed +24
-1
lines changed Original file line number Diff line number Diff line change 135
135
| 501 | [ Find Mode in Binary Search Tree] ( https://leetcode.com/problems/find-mode-in-binary-search-tree ) | Easy | [ ![ Java] ( https://img.icons8.com/color/40/000000/java-coffee-cup-logo.png )] ( src/FindModeInBinarySearchTree.java ) [ ![ Python] ( https://img.icons8.com/color/35/000000/python.png )] ( python/find_mode_in_binary_search_tree.py ) |
136
136
| 504 | [ Base 7] ( https://leetcode.com/problems/base-7 ) | Easy | [ ![ Java] ( https://img.icons8.com/color/40/000000/java-coffee-cup-logo.png )] ( src/Base7.java ) [ ![ Python] ( https://img.icons8.com/color/35/000000/python.png )] ( python/base_7.py ) |
137
137
| 506 | [ Relative Ranks] ( https://leetcode.com/problems/relative-ranks ) | Easy | [ ![ Java] ( https://img.icons8.com/color/40/000000/java-coffee-cup-logo.png )] ( src/RelativeRanks.java ) [ ![ Python] ( https://img.icons8.com/color/35/000000/python.png )] ( python/relative_ranks.py ) |
138
- | 507 | [ Perfect Number] ( https://leetcode.com/problems/perfect-number ) | Easy | |
138
+ | 507 | [ Perfect Number] ( https://leetcode.com/problems/perfect-number ) | Easy | [ ![ Java ] ( https://img.icons8.com/color/40/000000/java-coffee-cup-logo.png )] ( src/CheckPerfectNumber.java ) [ ![ Python ] ( https://img.icons8.com/color/35/000000/python.png )] ( python/check_perfect_number.py ) |
139
139
| 509 | [ Fibonacci Number] ( https://leetcode.com/problems/fibonacci-number ) | Easy | |
140
140
| 520 | [ Detect Capital] ( https://leetcode.com/problems/detect-capital ) | Easy | |
141
141
| 521 | [ Longest Uncommon Subsequence I] ( https://leetcode.com/problems/longest-uncommon-subsequence-i ) | Easy | |
Original file line number Diff line number Diff line change
1
+ class Solution :
2
+ def checkPerfectNumber (self , num : int ) -> bool :
3
+ if num == 1 : return False
4
+
5
+ divisior_sum , divisior = 0 , 1
6
+ while divisior * divisior <= num :
7
+ if num % divisior == 0 :
8
+ divisior_sum += (divisior + num // divisior )
9
+ divisior += 1
10
+ return divisior_sum == num
Original file line number Diff line number Diff line change
1
+ public class CheckPerfectNumber {
2
+ public boolean checkPerfectNumber (int number ) {
3
+ if (number == 1 ) return false ;
4
+
5
+ int sum = 0 ;
6
+ for (int divisor = 2 ; divisor * divisor <= number ; divisor ++) {
7
+ if (number % divisor == 0 ) {
8
+ sum += divisor + number / divisor ;
9
+ }
10
+ }
11
+ return sum + 1 == number ;
12
+ }
13
+ }
You can’t perform that action at this time.
0 commit comments