#1390
Four Divisors
specialist · 790 · lc medium +31 · verified · 56.6% accepted · 888 likes · top 51%
Description
Given an integer array nums, for each element that has exactly four divisors, add the sum of those divisors to a running total. Return the total, or 0 if no element has exactly four divisors.
Example 1:
Input: nums = [21,4,7]
Output: 32
Explanation:
21 has 4 divisors: 1, 3, 7, 21
4 has 3 divisors: 1, 2, 4
7 has 2 divisors: 1, 7
The answer is the sum of divisors of 21 only.
Example 2:
Input: nums = [21,21]
Output: 64
Example 3:
Input: nums = [1,2,3,4,5]
Output: 0
Code
1
2
3