kyu_5.integers_recreation_one package

Submodules

kyu_5.integers_recreation_one.solution module

kyu_5.integers_recreation_one.solution.digital_root(num: str) → int[source]

The digital root or digital sum of a non-negative integer is the single-digit value obtained by an iterative process of summing digits, on each iteration using the result from the previous iteration to compute the digit sum. The process continues until a single-digit number is reached.

Parameters

num – a digit/number/integer

Returns

digital root

kyu_5.integers_recreation_one.solution.divisor_generator(n: int)[source]

The best way to get all the divisors of a number.

Parameters

n – integers

Returns

all dividers of n

kyu_5.integers_recreation_one.solution.is_perfect_square(n: str) → bool[source]

Check if a number is a perfect square. (number made by squaring a whole number: 4 * $ = 16).

Parameters

n – integer

Returns

bool

kyu_5.integers_recreation_one.solution.list_squared(m: int, n: int) → list[source]

Given two integers m, n (1 <= m <= n) we want to find all integers between m and n whose sum of squared divisors is itself a square.

Parameters
  • m – start

  • n – end

Returns

list of integers between m and n whose sum of squared divisors is itself a square

kyu_5.integers_recreation_one.test_list_squared module

class kyu_5.integers_recreation_one.test_list_squared.ListSquaredTestCase(methodName='runTest')[source]

Bases: unittest.case.TestCase

Integers: Recreation One

Divisors of 42 are : 1, 2, 3, 6, 7, 14, 21, 42. These divisors squared are: 1, 4, 9, 36, 49, 196, 441, 1764. The sum of the squared divisors is 2500 which is 50 * 50, a square!

Given two integers m, n (1 <= m <= n) we want to find all integers between m and n whose sum of squared divisors is itself a square. 42 is such a number.

The result should be an array of arrays or of tuples (in C an array of Pair) or a string, each sub-array having two elements, first the number whose squared divisors is a square and then the sum of the squared divisors.

test_flatten()[source]

Testing list_squared function

Returns

Module contents