Counting sort initialization of the output array, each take time. Therefore, the time for the whole algorithm is the sum of the times for these steps, . Because it uses arrays of length and , the total space usage of the algorithm is also . For problem instances in which the maximum key value is significantly smaller than the number of items, counting sort can be highly space-efficient, as the only storage it uses other than its input and output arrays is the Count array which uses space . If each item to be sorted is itself an integer, and used as
Harshad number Stated mathematically, let be a positive integer with digits when written in base , and let the digits be formula_1 (formula_2). (It follows that formula_1 must be either zero or a positive integer up to .) can be expressed as If there exists an integer such that the following holds, then is a harshad number in base : A number which is a harshad number in every number base is called an all-harshad number, or an all-Niven number. There are only four all-harshad numbers: 1, 2, 4, and 6 (The number 12 is a harshad number in all bases except