blob: 7c8d08653fce28502e1ce16f8fc22c28dbc0ced3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
TASK #1 - Integer Square Root
You are given a positive integer $N.
Write a script to calculate the integer square root of the given number.
Please avoid using a built-in function. Find out more about it:
https://en.wikipedia.org/wiki/Integer_square_root
Examples
Input: $N = 10
Output: 3
Input: $N = 27
Output: 5
Input: $N = 85
Output: 9
Input: $N = 101
Output: 10
MY NOTES: Pretty easy as the Wikipedia page shows a C implementation
TASK #2 - Smith Numbers
Write a script to generate first 10 Smith Numbers in base 10.
According to Wikipedia:
"In number theory, a Smith number is a composite number for which, in
a given number base, the sum of its digits is equal to the sum of the
digits in its prime factorization in the given number base."
MY NOTES: Ok, an example in the Wikipedia clarifies this:
4937775 = 3**1 5**2 658371 (prime factors)
4 + 9 + 3 + 7 + 7 + 7 + 5 = 42
3 x� 1 + 5x 2 + (6 + 5 + 8 + 3 + 7) x 1 = 42 too
Should be quite straightforward.
|