Números felices
Números que alcanzan el 1 mediante la suma iterada de los cuadrados de sus dígitos: donde las matemáticas se encuentran con la alegría
Un número feliz se define mediante un proceso simple: toma cualquier entero positivo, reemplázalo por la suma de los cuadrados de sus dígitos y repite. Si este proceso llega finalmente al 1, el número es feliz. Si entra en un bucle sin fin sin alcanzar nunca el 1, el número es infeliz. Este concepto engañosamente simple conduce a ricas estructuras matemáticas y conexiones con los números primos.
¿Cómo funciona el algoritmo de la felicidad?
El proceso es sencillo: toma cada dígito del número, elévalo al cuadrado y suma todos los cuadrados. Luego repite con el resultado. Todo número o bien alcanza el 1 (feliz) o entra en el ciclo 4 → 16 → 37 → 58 → 89 → 145 → 42 → 20 → 4 (infeliz).
Ejemplo: ¿Es 23 feliz?
¡¡23 es un número feliz!
Ejemplo: ¿Es 4 feliz?
¡4 es un número infeliz — ¡entra en un bucle infinito!
Propiedades de los números felices
- Los primeros números felices son: 1, 7, 10, 13, 19, 23, 28, 31, 32, 44, 49, 68, 70, 79, 82, 86, 91, 94, 97, 100...
- Aproximadamente el 14,3% de todos los enteros positivos son números felices.
- Todo número infeliz entra finalmente en el mismo ciclo de 8 números: 4 → 16 → 37 → 58 → 89 → 145 → 42 → 20.
- Si un número es feliz, entonces todo número en su secuencia de iteración también es feliz.
Primos felices
Un primo feliz es un número que es a la vez feliz y primo. Estos números doblemente especiales combinan dos propiedades matemáticas independientes. Aparecieron en un episodio de 2007 de Doctor Who, llevando las matemáticas recreativas a la televisión mainstream.
Números felices en la cultura
Los números felices ganaron atención popular cuando aparecieron en el episodio de Doctor Who "42" (2007), donde la tripulación de una nave espacial tenía que identificar primos felices para desbloquear puertas de seguridad. El concepto fue introducido matemáticamente por Reg Allenby en 1966 y desde entonces se ha convertido en un tema popular en las matemáticas recreativas y los desafíos de programación.
Números felices hasta 500
Hay 76 números felices entre 1 y 500. Haz clic en cualquiera para ver su análisis completo.
Sabías que
- Exactly one cycle (of length 8) contains all sad numbers: [4,16,37,58,89,145,42,20]. Every unhappy number eventually reaches this cycle regardless of starting value. This unique cycle structure means the happy/sad binary classification is absolute—no number occupies middle ground; every number is either happy or eventually reaches this specific cycle.
- The proportion of happy numbers among first n integers stabilizes around 14.3% for all tested ranges. Among 1 to 143, exactly 20 are happy (13.9%); among 1 to 1000, approximately 143 are happy (14.3%). This remarkable stability across different scales suggests fundamental mathematical structure underlying happy number distribution.
- The smallest happy number is 1, the next smallest is 7. But 10, appearing before 13, surprises many—10→1²+0²=1 makes it happy. This demonstrates how leading zeros in digit squaring affect outcomes; positioning and digit values matter significantly.
- In base 2 (binary), the concept generalizes: happy numbers can be defined for any base, though the definition requires modification for bases where cyclic behavior differs. Some bases have no cycles, some single cycles, others multiple cycles. The structural difference between bases reveals how abstract the happy number concept truly is.
- The mathematical literature on happy numbers is surprisingly limited despite simple definitions, suggesting the concept remains underexplored compared to classical number types. Papers addressing happy number properties remain scarce, with major questions about distribution and theoretical foundations remaining open.
Preguntas Frecuentes
How do you determine if a number is happy?
Apply the digit-squaring algorithm: take any positive integer, replace it with the sum of squares of its digits, and repeat. Track results in a set. If reaching 1, the number is happy. If encountering a previously seen value (detecting a cycle), the number is unhappy. For example, 23: 2²+3²=13; 1²+3²=10; 1²+0²=1 (happy). For 2: 2²=4; 4²=16; 1²+6²=37; 3²+7²=58; 5²+8²=89; 8²+9²=145; 1²+4²+5²=42; 4²+2²=20; 2²+0²=4 (cycle detected at 4, unhappy). Most implementations use a set to track seen values, enabling cycle detection upon re-encountering. Programming requires iteration handling, digit extraction, and summation. Manual calculation becomes tedious for large numbers with many iterations.
Why are there exactly 20 happy numbers from 1 to 143?
This represents empirical observation of happy number distribution rather than following obvious pattern. The specific count (20/143 ≈ 14%) matches the long-term frequency (approximately 1 in 7 numbers). The relatively uniform distribution across different ranges suggests happy numbers distribute independently of digit patterns. Different ranges contain varying happy number patterns; some ranges might have 13 in 130 numbers, others 21 in 150 numbers—but averaging across large ranges yields consistent ~14.3% proportion. No closed formula predicts how many happy numbers exist up to n; the count requires iterative checking. The stability of this proportion across ranges, despite lacking simple explanation, demonstrates deep mathematical structure. Research continues investigating why this proportion stabilizes so predictably.
What exactly is the cycle that unhappy numbers reach?
The unhappy cycle in base 10 is [4, 16, 37, 58, 89, 145, 42, 20], of length 8. Starting from any unhappy number, repeated digit-squaring and summation eventually produces one of these values, after which the sequence cycles through these eight numbers repeatedly. For example, 2→4→16→37→58→89→145→42→20→4→16→... Every unhappy number is guaranteed to reach this cycle regardless of starting value. No other cycles exist in base 10 (proven through exhaustive analysis). The uniqueness of this cycle means all unhappy numbers share identical ultimate behavior—cyclical repetition through the same eight-element sequence. This structure contrasts with happy numbers reaching 1 directly. The deterministic behavior of sad numbers makes them mathematically interesting—despite varied paths, all converge to identical behavior.