Problem · Math

Get Data Dependence Sum (Fungible :)

Learn this problem
HardAmazon logoAmazonINTERNOA
See Amazon hiring insights

Problem statement

Data analysts at Amazon are analyzing time-series data. It was concluded that the data of the nth item was dependent on the data of some xth day if there is a positive integer k such that floor(n / k) = x where floor() represents the largest integer less than or equal to z.

Given n, find the sum of all the days' numbers on which the data of the xth (0 ≤ x < n) will be dependent.

Function

getDataDependenceSum(n: long) → long

Complete the function getDataDependenceSum in the editor below.

getDataDependenceSum takes the following arguments:

  1. long int n: the day to analyze the data dependency for

Returns

long int: the sum of days on which the data is dependent

Input Format For Custom Testing

The first line contains a long integer, n.

🌷, As always, a supa huge TY to tomtom, spike and aikay! You three da best 4ever!! 🐡 🐡 🐡

Examples

Example 1

n = 13return = 29
The data of the n = 13th day is dependent on [0, 1, 2, 3, 4, 6, 13] obtained for k = [14, 13, 6, 4, 3, 2, 1].

Example 2

n = 1return = 1
The only dependency is 1.

Example 3

n = 5return = 8
Example 3 illustration
Hence, the answer is 0 + 1 + 2 + 5 == 8 :)

Constraints

1 ≤ n ≤ 10^10

More Amazon problems

drafts saved locally
public long getDataDependenceSum(long n) {
  // write your code here
}
n13
expected29
checking account