Be happy - MATLAB Cody - MATLAB Central

Problem 45250. Be happy

Difficulty:Rate

check whether the given number is happy in b-base.

  • A happy number can be defined as a number which will yield 1 when it is replaced by the sum of the square of its digits repeatedly. If this process results in an endless cycle of numbers containing 4, then the number is called an unhappy number.

This is the case for base-10. For other bases, different scenerios would occur.

https://en.wikipedia.org/wiki/Happy_number

Solution Stats

47.19% Correct | 52.81% Incorrect
Last Solution submitted on Feb 23, 2025

Problem Comments

Solution Comments

Show comments
PIVlab surpasses 100K all-time File Exchange downloads
During the past twelve months, PIVlab, a MATLAB Community Toolbox for particle...
4
8
LLMs with MATLAB updated to support the latest OpenAI Models
Large Languge model with MATLAB, a free add-on that lets you access...
2
4

Group

Number theory Image
Number theory
  • 44 Problems
  • 21 Finishers

Problem Recent Solvers32

Problem Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!