# Happy Numbers

DevFeed: [Happy Numbers](<https://devfeed.tech/articles/happy-numbers-34383.md>)

Original publisher: [Read original article](<https://tapoueh.org/blog/2010/08/happy-numbers/>)

Author: Dimitri Fontaine PostgreSQL Major Contributor; Author

Published: 2010-08-30T09:00:00Z

Content type: article

Language: en

Sources: [Dimitri Fontaine](<https://devfeed.tech/sources/dimitri-fontaine.md>)

Topics: [Lisp](<https://devfeed.tech/topics/lisp.md>), [Code](<https://devfeed.tech/topics/code.md>), [Emacs](<https://devfeed.tech/topics/emacs.md>), [function](<https://devfeed.tech/topics/function.md>), [test](<https://devfeed.tech/topics/test.md>)

Tags: [article](<https://devfeed.tech/tags/article.md>), [code](<https://devfeed.tech/tags/code.md>), [emacs](<https://devfeed.tech/tags/emacs.md>), [emacs-lisp](<https://devfeed.tech/tags/emacs-lisp.md>), [function](<https://devfeed.tech/tags/function.md>), [lisp](<https://devfeed.tech/tags/lisp.md>), [test](<https://devfeed.tech/tags/test.md>)

## AI overview

The article explains happy numbers, whose repeated sum-of-squares-of-digits process either reaches 1 or enters a cycle. It describes implementations of the calculation in Emacs Lisp and a recursive query, including cycle prevention and a reusable function.

## Source excerpt

After discovering the excellent Gwene service, which allows you to subscribe to newsgroups to read RSS content ( blogs, planets, commits, etc), I came to read this nice article about Happy Numbers. That's a little problem that fits well an interview style question, so I first solved it yesterday evening in Emacs Lisp as that's the language I use the most those days. A happy number is defined by the following process. 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 ends in 1 are happy numbers, while those that do not end in 1 are unhappy numbers (or sad numbers).