Nombres heureux
Des nombres qui atteignent 1 par la somme itérée des carrés de leurs chiffres : quand les maths rencontrent la joie
Un nombre heureux est défini par un processus simple : prenez n'importe quel entier positif, remplacez-le par la somme des carrés de ses chiffres, et répétez. Si ce processus atteint finalement 1, le nombre est heureux. S'il boucle sans fin sans jamais atteindre 1, le nombre est malheureux. Ce concept trompeusement simple mène à de riches structures mathématiques et des connexions avec les nombres premiers.
Comment fonctionne l'algorithme du bonheur ?
Le processus est simple : prenez chaque chiffre du nombre, élevez-le au carré et additionnez tous les carrés. Puis répétez avec le résultat. Tout nombre atteint soit 1 (heureux) soit entre dans le cycle 4 → 16 → 37 → 58 → 89 → 145 → 42 → 20 → 4 (malheureux).
Exemple : 23 est-il heureux ?
¡23 est un nombre heureux !
Exemple : 4 est-il heureux ?
¡4 est un nombre malheureux — il entre dans une boucle infinie !
Propriétés des nombres heureux
- Les premiers nombres heureux sont : 1, 7, 10, 13, 19, 23, 28, 31, 32, 44, 49, 68, 70, 79, 82, 86, 91, 94, 97, 100...
- Environ 14,3 % de tous les entiers positifs sont des nombres heureux.
- Tout nombre malheureux entre finalement dans le même cycle de 8 nombres : 4 → 16 → 37 → 58 → 89 → 145 → 42 → 20.
- Si un nombre est heureux, alors tout nombre dans sa séquence d'itération est aussi heureux.
Nombres premiers heureux
Un nombre premier heureux est un nombre qui est à la fois heureux et premier. Ces nombres doublement spéciaux combinent deux propriétés mathématiques indépendantes. Ils ont été présentés dans un épisode de 2007 de Doctor Who, portant les mathématiques récréatives à la télévision grand public.
Nombres heureux dans la culture
Les nombres heureux ont gagné l'attention du public lorsqu'ils sont apparus dans l'épisode de Doctor Who "42" (2007), où l'équipage d'un vaisseau spatial devait identifier des nombres premiers heureux pour déverrouiller des portes de sécurité. Le concept a été introduit mathématiquement par Reg Allenby en 1966 et est depuis devenu un sujet populaire en mathématiques récréatives et dans les défis de programmation.
Nombres heureux jusqu'à 500
Il y a 76 nombres heureux entre 1 et 500. Cliquez sur l'un d'eux pour voir son analyse complète.
Le saviez-vous
- 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.