aboutsummaryrefslogtreecommitdiff
path: root/challenge-159/duncan-c-white/README
blob: c512a02d6945a83e41ff4e40266e5ef2c51bc922 (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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
TASK #1 - Farey Sequence

You are given a positive number, $n.

Write a script to compute the Farey Sequence of the order $n, defined as:
is the sequence of completely reduced fractions, between 0 and 1,
which have numerators and denominators less than or equal to n,
arranged in order of increasing size).

Example 1:

	Input: $n = 5
	Output: 0/1, 1/5, 1/4, 1/3, 2/5, 1/2, 3/5, 2/3, 3/4, 4/5, 1/1.

Example 2:

	Input: $n = 7
	Output: 0/1, 1/7, 1/6, 1/5, 1/4, 2/7, 1/3, 2/5, 3/7, 1/2, 4/7,
	        3/5, 2/3, 5/7, 3/4, 4/5, 5/6, 6/7, 1/1.

Example 3:

	Input: $n = 4
	Output: 0/1, 1/4, 1/3, 1/2, 2/3, 3/4, 1/1.

MY NOTES: ok.  Pretty easy.  Will need a way to reduce fractions, and a way of
storing that reduced fraction in a set (storing "Num/Denom" should do it).


TASK #2 - Moebius Number

You are given a positive number $n.

Write a script to generate the Moebius Number for the given number,
definition: For any positive integer n, define moeb(n) as:

    moeb(n) = +1 if n is a square-free positive integer with an even
    	         number of prime factors.
    moeb(n) = 1 if n is a square-free positive integer with an odd
    	         number of prime factors.
    moeb(n) = 0 if n has a squared prime factor.

Example 1:

	Input: $n = 5
	Output: -1

Example 2:

	Input: $n = 10
	Output: 1

Example 3:

	Input: $n = 20
	Output: 0

MY NOTES: ok.  Slightly tricky.