number

package
v0.0.0-...-e6e6e0f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 25, 2026 License: BSD-3-Clause Imports: 1 Imported by: 0

README

NAME

20 - is number happy

DESCRIPTION

Problem

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

Report wither an integer positive number is "happy".

Definition: a number is "happy" if iterative sum of squares of its digits is equal to 1.

Example

Number: 13

Output: Yes, because:

1^2 + 3^2 = 10 = 1^2 + 0^2 = 1

SEE ALSO

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsHappyNumber

func IsHappyNumber(n int) bool

IsHappyNumber reports if the number n is "happy", i.e., iterative sum of squares of its digits leads to 1.

Example
package main

import (
	"fmt"

	"github.com/skhal/lab/iq/20/number"
)

func main() {
	fmt.Println(number.IsHappyNumber(1))
	fmt.Println(number.IsHappyNumber(2))
}
Output:
true
false

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL