aboutsummaryrefslogtreecommitdiff
path: root/challenge-164/duncan-c-white/README
blob: 06b7a108f4cb1aba74ab2d7168445142724ed071 (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 - Prime Palindrome

Write a script to find all prime numbers less than 1000, which are also
palindromes in base 10. Palindromic numbers are numbers whose digits
are the same in reverse. For example, 313 is a palindromic prime, but
337 is not, even though 733 (337 reversed) is also prime.

MY NOTES: ok.  Pretty easy.

GUEST LANGUAGE: As a bonus, I also had a go at translating ch-1.pl
into C (look in the C directory for that).


TASK #2 - Happy Numbers

Write a script to find the first 8 Happy Numbers in base 10. For more
information, please check out https://en.wikipedia.org/wiki/Happy_number

Starting with any positive integer, replace the number by the sum of the
squares of its digits, and repeat the process until the number equals 1
(where it will stay), or it loops endlessly in a cycle which does not
include 1.

Those numbers for which this process end in 1 are happy numbers, while
those numbers that do not end in 1 are unhappy numbers.

Example

19 is a Happy Number in base 10, as shown:

19 => 1^2 + 9^2
   => 1   + 81
   => 82 => 8^2 + 2^2
         => 64  + 4
         => 68 => 6^2 + 8^2
               => 36  + 64
               => 100 => 1^2 + 0^2 + 0^2
                      => 1 + 0 + 0
                      => 1

MY NOTES: seems very easy.  Loop detection is surely just a set of values
that we've already seen.

GUEST LANGUAGE: As a bonus, I also had a go at translating ch-2.pl
into C (look in the C directory for that).