Saturday, September 12, 2020

Casio fx-9750GIII: Happy Integers

Casio fx-9750GIII: Happy Integers


What Makes an Integer Happy?  

1.  Take a positive integer

2.  Take the sum of the squares of its integers

3.  Repeat the process until:


a.   You repeat a previous result or

b.   You obtain a sum of 1.  


In the cases that you eventually reach 1, that number is defined as a happy integer.


23:

2^2 + 3^2 = 13

1^2 + 3^2 = 10

1^2 + 0^2 = 1

23 is a happy integer.  


24:

2^2 + 2^2 = 4

4^2 = 16

1^2 + 6^2 = 37

3^2 + 7^2 = 58

5^2 + 8^2 = 89

8^2 + 9^2 = 145

1^2 + 4^2 + 5^2 = 42

4^2 + 2^2 = 20

2^2 + 0^2 = 4    (see first addition - repeat)

24 is not a happy integer.

The sequence of sums of squares of the integer's digits is known as a cherry sequence.  


Casio fx-9750GIII: HAPPY

(316 bytes)


"2020-08-20 EWS"

"N>0, INTEGER: N"? → N

{ 0 } → List 1

Intg log N → D

N ÷ 10^D → W

Lbl 3

0 → T

For 0 → I To D

T + (Intg W)^2 → T

(W - Intg W) × 10 → W

Next

Augment(List 1, { T }) → List 1

ClrText

Locate 1, 4, T

For 1 → I To 100

Next

T = 1 ⇒ Goto 1

For 1 → I To Dim List 1 - 1

T = List 1[ I ] ⇒ Goto 2

Next

T → W

Intg log W → D

W ÷ 10^D → W

Goto 3

Lbl 1

ClrText

Locate 1, 3, W

Locate 1, 4,"IS A HAPPY INTEGER"

Stop

Lbl 2

Locate 1, 3, N

Locate 1, 4, "NOT A HAPPY INTEGER"

Stop


Notes:

(1)  10^ is shown as a subscript 10 on the calculator.

(2)  The program sequence

ClrText

Locate 1, 4, T

For 1 → I To 100

Next

creates a timer.  This allows the calculator to show intermediate results for a short time.

(3)  Intermediate sums of squares are stored in List 1.  Other than the first 0 (an element is required to start a list in Casio programming), the rest of the sequence is known as Cheery Sequence.


Examples

N = 19;  Happy Number

N = 77; Not a Happy Number

N = 230; Happy Number

N = 562; Not a Happy Number 


Sources:

Duncan, Donald C.  Happy Integers.  The Mathematics Teacher, Vol 65. No. 7  November 1972, pp. 627-629  https://www.jstor.org/stable/27959021 

Happy Number.  GeeksforGreeks.  https://www.geeksforgreeks.org/happy-number  Updated February 4, 2020.  Accessed August 19, 2020.  (website under maintenance)

Eddie

All original content copyright, © 2011-2020.  Edward Shore.   Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited.  This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author. 


Spotlight: TI-55 from 1977

Spotlight: TI-55 from 1977 Welcome to a special Monday Edition of Eddie’s Math and Calculator Blog. Today, we have the origi...