Statistics

Problem Statement for "Divisors"

Problem Statement

PROBLEM STATEMENT

Given an int[], return the total number of factors of every element, not
counting duplicates between elements.

k is a factor of N if k is a positive integer and there exists a positive
integer m such that k*m = N.
If N = 12, then k = 2 would be a factor since 2 * 6 = 12.
k = 5 would not be a factor since there is no positive integer m such that 5 *
m = 12.

As an example, if the int[] was {12, 24, 15}:

The factors of 12 are {1,2,3,4,6,12}
The factors of 24 are {1,2,3,4,6,8,12,24}
The factors of 15 are {1,3,5,15}

The total set of factors, not including duplicates is {1,2,3,4,5,6,8,12,15,24}
This set has 10 elements, so your method would return 10.


DEFINITION

Class: Divisors
Method: numFactors
Parameters: int[]
Returns: int
Method signature (be sure your method is public):  int numFactors(int[] numbers);

NOTES

TopCoder will ensure the validity of the inputs.  Inputs are valid if all of
the following criteria are met:
- numbers will have between 1 and 50 elements, inclusive
- each element of numbers will be between 1 and 1,000,000,000 inclusive.

EXAMPLES

(1)
numbers: {12,15,24}
your method would return: 10

(2)
numbers: {9}
your method would return: 3

(3)
numbers: {37}
your method would return: 2

(4)
numbers: {32,48}
your method would return: 11

(5)
numbers: {673873200,671846400}
your method would return: 1386

(6)
numbers:
{1996,1997,1998,1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010}
your method would return: 96

Definition

Class:
Divisors
Method:
numFactors
Parameters:
int[]
Returns:
int
Method signature:
int numFactors(int[] param0)
(be sure your method is public)

Constraints

    Examples


      This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2024, TopCoder, Inc. All rights reserved.
      This problem was used for: