Lucky Number Calculator
Enter a positive integer to see whether it is a happy number. The calculator repeatedly adds the squares of its digits and checks whether the sequence reaches 1.
Lucky Number
Lucky Number Formula
Where:
- \(n_0\) — the positive integer you enter.
- \(n_j\) — the number at step \(j\) of the sequence.
- \(d_i\) — a decimal digit of \(n_j\), from 0 to 9.
- \(S(n)\) — the sum of the squares of the digits of \(n\).
Apply the digit-square sum repeatedly. If the sequence reaches 1, the starting number is happy; if a number repeats before reaching 1, it is not happy.
Lucky Number – Calculation Example
Example: enter the default value, 7, and square its digits at each step.
\[\begin{aligned}7&\to 7^2=49\\49&\to 4^2+9^2=97\\97&\to 9^2+7^2=130\\130&\to 1^2+3^2+0^2=10\\10&\to 1^2+0^2=1\end{aligned}\]
Result: 7 is happy because its sequence reaches 1.
How to use the calculator
- Enter a whole number greater than zero in the Positive Integer field. The default value is 7.
- Read the Result: it says whether the number is happy or not happy.
- To check another number, replace the entry and read the updated result.
The result is a classification, not a score. It does not show the intermediate sequence, so you can follow the worked example above if you want to see how the test operates.
What is a happy number?
A happy number is a positive integer that eventually becomes 1 when you repeatedly replace it with the sum of the squares of its decimal digits. Once a sequence reaches 1, it stays there: \(1^2=1\). The default value, 7, is happy because its sequence reaches 1 after five replacements.
A sequence that does not reach 1 eventually repeats a number and continues in a cycle. For example, 4 leads through \(4\to16\to37\to58\to89\to145\to42\to20\to4\). Because this returns to 4 without reaching 1, 4 is not happy. The calculator remembers the numbers it has seen and stops when it finds either 1 or a repeated number; it does not need to run indefinitely.
Despite this page’s name, the test is for happy numbers. In mathematics, “lucky numbers” can also mean a different set produced by a number-sieving process. A happy result here says something about digit arithmetic—not about chance, good fortune, or what will happen to you. If you are exploring numbers for their symbolic meaning instead, the numerology by name and date of birth calculator uses a different approach.
Assumptions and practical tips
- Use positive whole numbers. Zero and negative numbers are not valid inputs for this calculator. Enter digits such as 19 or 123 rather than a fraction.
- Digits are read in base 10. The calculation squares the familiar decimal digits 0 through 9. Writing the same quantity in another number base would give a different digit sequence.
- Avoid decimals and exponent notation. The calculator parses the beginning of the entry as an integer, so an entry such as 7.8 may be treated as 7 rather than rejected. Type the intended whole number directly.
- Be cautious with very large integers. The calculation uses JavaScript numbers, which cannot represent every integer above \(9{,}007{,}199{,}254{,}740{,}991\) exactly. An imprecise input may produce an unreliable classification.
You can test nearby numbers to see how different their paths may be. For instance, 7 is happy, while 8 enters a repeating cycle and is not happy. There is no rule that consecutive numbers must share the same result. Like the Zodiac Sign calculator, this page assigns a label to an input—but here the label follows a specific, repeatable arithmetic rule.
Frequently Asked Questions
How can I check whether a number is happy by hand?
Write down each digit-square sum until you reach 1 or a number you have already written. For example, \(19\to82\to68\to100\to1\), so 19 is happy. Keep a short list of results as you go; a repeated result means the sequence will follow the same path again and never reach 1.
Do all unhappy numbers enter the same cycle?
Yes. In base 10, every positive integer that does not reach 1 eventually enters the cycle \(4\to16\to37\to58\to89\to145\to42\to20\to4\). For a quick hand check, you can stop as soon as you reach any number in that cycle. The starting number does not have to be 4.
Does rearranging a number's digits change whether it is happy?
No. Rearranging the same digits leaves their first digit-square sum unchanged, so the rest of the sequence is identical. For instance, 19 and 91 both first become \(1^2+9^2=82\); both are happy. This applies to any permutation of the digits, provided it represents a positive integer.
Does adding zeros change whether a number is happy?
No. A zero contributes \(0^2=0\), so inserting a zero or appending one does not change the first digit-square sum. Thus 19, 109, and 190 all follow the same sequence after one step and are all happy. Leading zeros likewise do not change the integer's value.
Is a happy number the same as a prime number?
No. Happiness depends on a sequence of digit calculations; primality depends on whether a number has divisors other than 1 and itself. The prime number 7 is happy, but the prime number 2 is not. The composite number 10 is happy. Neither property guarantees the other.
Are there units to convert, or does the number base matter?
Happy numbers have no physical units, so there is no unit conversion. The numeral base does matter because it determines the digits being squared. For example, decimal 3 is not happy, while its binary representation \(11_2\) reaches \(10_2\), then \(1_2\) under the binary-digit version of the rule. This calculator uses decimal digits.
Which single-digit numbers are happy?
Among the positive single-digit integers, only 1 and 7 are happy. The others eventually enter a repeating cycle instead of reaching 1. A happy result is not a rating or a measure of how “good” a number is—it identifies whether that number follows a particular arithmetic path.