A number is perfect if is equal to the sum of its proper divisors i.e. the sum of its positive divisors excluding the number itself.
Input: L1 = 3 -> 6 -> 9
Proper divisor sum of 3 = 1
Proper divisor sum of 6 = 1 + 2 + 3 = 6
Proper divisor sum of 9 = 1 + 3 = 4
Input: L1 = 17 -> 6 -> 10 -> 6 -> 4
Approach: Initialise sum = 0 and for every node of the list, find the sum of its proper divisors say sumFactors. If cur_node = sumFactors then update the resultant sum as sum = sum + cur_node. Print the sum in the end.
Below is the implementation of the above approach:
Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.
- Sum of all Palindrome Numbers present in a Linked list
- Sum of all perfect numbers present in an array
- Check if elements of Linked List are present in pair
- Sum of distances between the two nearest perfect squares to all the nodes of the given linked list
- Count numbers upto N which are both perfect square and perfect cube
- Sum of factorials of Prime numbers in a Linked list
- Multiply two numbers represented as linked lists into a third list
- Remove all nodes from a Doubly Linked List containing Fibonacci numbers
- Minimum and Maximum Prime Numbers of a Singly Linked List
- Create new linked list from two given linked list with greater element at each node
- Convert singly linked list into circular linked list
- Difference between Singly linked list and Doubly linked list
- Merge a linked list into another linked list at alternate positions
- XOR Linked List – A Memory Efficient Doubly Linked List | Set 2
- XOR Linked List - A Memory Efficient Doubly Linked List | Set 1
- Check if a linked list is Circular Linked List
- Convert Singly Linked List to XOR Linked List
- Sum of all palindrome numbers present in an Array
- Sum of all mersenne numbers present in an array
- Construct a Maximum Sum Linked List out of two Sorted Linked Lists having some Common nodes
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : Amal Kumar Choubey