C# – First steps with C# and .NET – part 020 .

The tutorial for today is about a math problem named happy number.
I used my repl.it account to test it.
The algorithm of this program is simple:
To find out if a number is happy, replace the number by the sum of the squares of its digits. Repeat the process until either the number equals 1 or loops endlessly in a cycle that does not include 1. When the process ends with 1 then the number is described as a happy number, otherwise, it is an unhappy number.
Let’s test for number 19:

You can test the C# source code at:

The source code of this program is this:

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.