Weaksauce!

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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
import Analytics.Theory.Number   -- http://lpaste.net/107480 for the Prime type

{--

As always (for now), these problems are from the P-99 Prolog problem set.

P40 Goldbach's conjecture.

Goldbach's conjecture says that every positive even number greater than 2 is the 
sum of two prime numbers. Example: 28 = 5 + 23. It is one of the most famous 
facts in number theory that has not been proved to be correct in the general 
case. It has been numerically confirmed up to very large numbers. Write a 
function to find the two prime numbers that sum up to a given even integer.

 --}

goldbach :: Integer -> Maybe (Prime, Prime)
goldbach n = undefined

{--

Example:

*Main> goldbach 28 ~> (5,23)

It is indeterminate how the function responds to an odd-numbered input ...
perhaps it explodes like a piñata? YAY! (candies!)

BONUS: create the even number type such that every call to goldbach is
type-guaranteed to succeed (so this number-line either has to start with
a FOUR-equivalent OR it fails on smaller even numbers).

... (or ... not. That rant was me getting my Peano on.)

And when I say 'type-guaranteed to succeed,' of course I mean, if and only
if Goldbach's conjecture is true for all cases.

Bonus-bonus: prove Goldbach's conjecture, or, provide a conterexample that
disproves it (and that's why I have the return type in the Maybe-Functor, in
case you were wondering about that). (Hey, it's not proved yet ... until you
prove it, that is.)

Good luck with that one.

Anyway.

P41 A list of Goldbach compositions.

Given a range of integers by its lower and upper limit, print a list of all even 
numbers and their Goldbach composition.

 --}

goldbachs :: Integer -> Integer -> [(Prime, Prime)]
goldbachs smaller larger = undefined

{--

Example:
*Main> goldbachs 9 20 ~>
[(3,7), (5,7), (3,11), (3,13), (5,13), (3,17)]

Which means, ya know:

10 = 3 + 7
12 = 5 + 7
14 = 3 + 11
16 = 3 + 13
18 = 5 + 13
20 = 3 + 17

-- One-liner challenge! -------------------------------------------------------

Given you have a function that rounds a number (up) to its closest even number, 
write the goldbachs function in one line.

-------------------------------------------------------------------------------

Continuing on ...

In most cases, if an even number is written as the sum of two prime numbers, one 
of them is very small. Very rarely, the primes are both bigger than say 50. Try 
to find out how many such cases there are in the range 4..3000.

How would you write this in Haskell?

 --}

goldbachsGT :: Integer -> Integer -> Integer -> [(Integer, (Prime, Prime))]
goldbachsGT a b greaterThan = undefined

{--

Example (for a prime floor of 50):

*Main> goldbachsGT 4 3000 50 ~>
[(992,(73,919)), (1382,(61,1321)), (1856,(67,1789)), (1928,(61,1867)),...]

What is the length of the returned list? How long did this function take?

Weaksauce: since we are just conjecturing here, we could say most anything,
right? I conjecture ... the sky is falling! Ya! Duck and cover, peeps!

 --}