You are given a 1-indexed integer array nums of length n. An element nums[i] of nums is called special if i divides n, i.e. n % i == 0. Return the sum of the squares of all special elements of nums.
You are given a 1-indexed integer array nums of length n. An element nums[i] of nums is called special if i divides n, i.e. n % i == 0. Return the sum of the squares of all special elements of nums.
Example 1:
Input: {"nums":[1,2,3,4]}
Output: 21
Constraints:
1≤nums.length==n≤50
1≤nums[i]≤50
Test Cases
Input (Stdin)
Expected Output (Stdout)
Execution Result
Run code to see results.
Input
arr ={"nums":[1,2,3,4]}
n = 4. A position i (counting from 1) is special when it divides n evenly, so only divisors of 4 count.