aboutsummaryrefslogtreecommitdiff
path: root/challenge-167/duncan-c-white/README
blob: e34765e0f06331ee2c8a249c3ae8a3ef5a7ed1df (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
TASK 1: Circular Prime

Write a script to find out first 10 circular primes having at least 3
digits (base 10).

Please checkout https://en.wikipedia.org/wiki/Circular_prime for more information.

A circular prime is a prime number with the property that the number
generated at each intermediate step when cyclically permuting its (base
10) digits will also be prime.

Quote from the Wikipedia page:

"For example, 1193 is a circular prime, since 1931, 9311 and 3119 all
are also prime.[3] A circular prime with at least two digits can only
consist of combinations of the digits 1, 3, 7 or 9, because having 0, 2,
4, 6 or 8 as the last digit makes the number divisible by 2, and having
0 or 5 as the last digit makes it divisible by 5"

OUTPUT

113, 197, 199, 337, 1193, 3779, 11939, 19937, 193939, 199933


MY NOTES: ok, sounds relatively easy.  The wikipedia page clarifies it.
I'm reusing my old favourite MakePrimes.pm.

HOWEVER, my solution finds far more circular primes than the above output
shows.  If 113 is a CP (and it is cos 131 and 311 are also prime), then SO
IS 131 AND SO IS 311, but the above list doesn't show it.  Also, my solution
computes ALL CPs with exactly N digits, rather than the first 10 with N or
more digits.


Task 2: Task 2: Gamma Function

Implement subroutine gamma() using the Lanczos approximation method.

Ryan Thompson wrote an interesting blog explaining the subject in
details. Highly recommended if you are looking for more information:
https://ry.ca/2022/05/lanczos-approximation

Example

print gamma(3); # 1.99
print gamma(5); # 24
print gamma(7); # 719.99

MY NOTES: Hell no.  Complex numbers, ridiculously complicated formula,
plus I've no idea what the Gamma function even is.  This is far too
mathematical for me, so I've no interest in doing it.