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:
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- 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
- Minimum and Maximum Prime Numbers of a Singly Linked List
- Remove all nodes from a Doubly Linked List containing Fibonacci numbers
- Create new linked list from two given linked list with greater element at each node
- Convert singly linked list into circular linked list
- Merge a linked list into another linked list at alternate positions
- Difference between Singly linked list and Doubly linked list
- XOR Linked List - A Memory Efficient Doubly Linked List | Set 1
- XOR Linked List – A Memory Efficient Doubly Linked List | Set 2
- Convert Singly Linked List to XOR Linked List
- Check if a linked list is Circular Linked List
- Construct a Maximum Sum Linked List out of two Sorted Linked Lists having some Common nodes
- Create a linked list from two linked lists by choosing max element at each position
- Sum of all mersenne numbers present in an array
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. 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.