Given the numbers 313, 331, 367 what comes next? Doctor Who fans will know.

This CodeNewbie Challenge is about finding Happy Primes. A prime number is one that is only divisible by itself and one. A happy number is a number that reduces to one when you take the sum of the squared digits and continue iterating it. An unhappy or sad number will continue iterating indefinitely.

For example 19 is a happy number:

1^{2} + 9^{2} = 82

8^{2} + 2^{2} = 68

6^{2} + 8^{2} = 100

1^{2} + 0^{2} + 0^{2} = 1

A happy prime is a number that is both happy and prime.

## The Challenge

The challenge is a math based coding and testing challenge. Your job is to find numbers that are happy primes.

### Level 1

In the first level you will start by producing a list of the happy primes below 100 from a list of primes and a list of happy numbers. Then take a user input and determine if that number is a happy prime or not.

Prime Numbers Below 100:

[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]

Happy Numbers Below 100:

[1, 7, 10, 13, 19, 23, 28, 31, 32, 44, 49, 68, 70, 79, 82, 86, 91, 94, 97, 100]

### Level 2

The second level starts where the first leaves off. You now need to find the happy primes from 0 - 500. Your challenge is to write code that generates a list of happy prime numbers between 0 and 500.

List of happy primes from level 1 (0-100) as a starting point:

[7, 13, 19, 23, 31, 79, 97]

Continue this list out to have all the happy primes from 0-500.

### Level 3

The third level puts components of levels one and two together to determine if a number entered is a happy prime and if not what the nearest happy prime is to that number.

Your challenge is to write code that will determine if a given number is a happy prime or not. If it is not give the nearest happy prime to the given number.

List of happy primes 0-500:

[7, 13, 19, 23, 31, 79, 97, 103, 109, 139, 167, 193, 239, 263, 293, 313, 331, 367, 379, 383, 397, 409, 487]

#### A step further

Write your code so that any number may be tested even above 500.