aboutsummaryrefslogtreecommitdiff
path: root/challenge-139/duncan-c-white/README
blob: d2eacb517a107bff72e87f3ca0da7aa0f8d63f3e (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
TASK #1 - JortSort

You are given a list of numbers.

Write a script to implement JortSort. It should return true/false
depending if the given list of numbers are already sorted.

Example 1:

	Input: @n = (1,2,3,4,5)
	Output: 1

	Since the array is sorted, it prints 1.

Example 2:

	Input: @n = (1,3,2,4,5)
	Output: 0

	Since the array is NOT sorted, it prints 0.

MY NOTES: Very easy.  Don't know what "JortSort" means, but this is
just the linear "IsSorted" function..


TASK #2 - Long Primes

Write a script to generate first 5 Long Primes.

A prime number (p) is called Long Prime if (1/p) has an infinite decimal expansion repeating every (p-1) digits.

Example

	7 is a long prime since 1/7 = 0.142857142857...
	The repeating part (142857) size is 6 i.e. one less than the prime number 7.

	Also 17 is a long prime since 1/17 = 0.05882352941176470588235294117647...
	The repeating part (0588235294117647) size is 16 i.e. one less than the prime number 17.

	Another example, 2 is not a long prime as 1/2 = 0.5.
	There is no repeating part in this case.

MY NOTES: Sounds pretty easy.  First generate some primes (have code to do that using Sieve of
        Erathosthenes).  Then check each prime p to see if 1/p's 2*p long decimal fraction
	contains the same sequence p-1 digits long.