FastPrepSum of Divisors of the Array GCD
Problems/Sum of Divisors of the Array GCD

Sum of Divisors of the Array GCD

Zscaler logoZscaler● EasyINTERNPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The report keeps the goal of the GCD and the sum of divisors but leaves out the input domain, the function interface, and the limits. Our version is about 82% the same as the reported question.

Given a nonempty array of positive integers values, compute the greatest common divisor of all values.

Return the sum of every positive divisor of that GCD.

Function

sumDivisorsOfArrayGcd(values: int[]) → long

Examples

Example 1

values = [6,12,18]return = 12

The array GCD is 6. Its positive divisors are 1, 2, 3, 6, whose sum is 12.

Example 2

values = [7,14]return = 8

The GCD is 7, so the divisor sum is 1 + 7 = 8.

Example 3

values = [8,16,32]return = 15

The GCD is 8. Its divisors 1, 2, 4, 8 sum to 15.

Constraints

  • 1 <= values.length <= 200000
  • 1 <= values[i] <= 10^9
  • The answer fits in a signed 64-bit integer.

More Zscaler interview questions

  • Rate Limiter with Hourly and Daily Effort QuotasPHONE SCREEN · Seen Jul 2026
  • Merging PalindromesPHONE SCREEN · Seen Sep 2024
  • Find the Element With Odd FrequencyPHONE SCREEN · Seen Jun 2024
  • Merge IntervalsPHONE SCREEN · Seen Jun 2024
  • Asteroid CollisionONSITE INTERVIEW · Seen Sep 2024
  • Check Whether a Byte Is NonzeroONSITE INTERVIEW · Seen Sep 2024
  • Count Vowel PermutationsONSITE INTERVIEW · Seen Sep 2024
  • Longest Common Subsequence LengthONSITE INTERVIEW · Seen Jun 2024
  • Run-Length EncodingONSITE INTERVIEW · Seen Jun 2024
  • How Many Sentences? 🌿OA · Seen Mar 2024

Similar questions at other companies

  • Automation Pipeline, Part 1: Single WorkerPlaid · PHONE SCREEN
  • Employee Count Median, Mean and ModeClay · PHONE SCREEN
  • Length of a Document Reached Through a Random TokenMercor · PHONE SCREEN
  • Apply Affine Array TransformationsByteDance · PHONE SCREEN
  • Exponential Backoff DelaysWonderful · PHONE SCREEN
  • One-Nearest-Neighbor Classification with Manhattan DistanceOpenAI · PHONE SCREEN
  • Recover Document Hierarchy from IndentationReducto · PHONE SCREEN
  • Average Grades per StudentHartford Financial Services · PHONE SCREEN
  • Through-Origin Linear RegressionMeta · PHONE SCREEN
  • Latency Bucket CounterDatadog · OA · PHONE SCREEN

Interview reports that mention this question

  • Zscaler SDE C++ and OS Rounds: 7 Experiences (Part 2 of 6)
  • Zscaler Campus SDE Interviews: 37 Experiences (Part 1 of 6)

Zscaler interview experiences

  • Zscaler Campus Drive Interviews: 4 Experiences (Part 6 of 6)
  • Zscaler Java, QA and Cloud Rounds: 8 Experiences (Part 5 of 6)
  • Zscaler UI and DevTest Rounds: 8 Experiences (Part 4 of 6)
  • Zscaler Intern, QA and SRE Rounds: 7 Experiences (Part 3 of 6)
See Zscaler hiring insights
Saved
class Solution {
    public long sumDivisorsOfArrayGcd(int[] values) {
      // write your code here
    }
}
Checking account…