<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://learn.cemetech.net/index.php?action=history&amp;feed=atom&amp;title=TI-BASIC%3AHappynumber</id>
	<title>TI-BASIC:Happynumber - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://learn.cemetech.net/index.php?action=history&amp;feed=atom&amp;title=TI-BASIC%3AHappynumber"/>
	<link rel="alternate" type="text/html" href="http://learn.cemetech.net/index.php?title=TI-BASIC:Happynumber&amp;action=history"/>
	<updated>2026-05-28T01:35:08Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.3</generator>
	<entry>
		<id>http://learn.cemetech.net/index.php?title=TI-BASIC:Happynumber&amp;diff=805&amp;oldid=prev</id>
		<title>Maintenance script: Initial automated import</title>
		<link rel="alternate" type="text/html" href="http://learn.cemetech.net/index.php?title=TI-BASIC:Happynumber&amp;diff=805&amp;oldid=prev"/>
		<updated>2016-02-24T18:19:30Z</updated>

		<summary type="html">&lt;p&gt;Initial automated import&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;This is a program to find out if any number from 1 to 999 is a happy number. Before I put the code in though, some of you may be wondering what a happy number is though.&lt;br /&gt;
To find a happy number:&lt;br /&gt;
Take X (Ex. 123)&lt;br /&gt;
Take each of the digits in X and square them (Ex. 1²,2²,3²)&lt;br /&gt;
Add the squares (Ex. 1+4+9=14)&lt;br /&gt;
Keep on doing this until you get either 1 or 4. If you get 1, the number is happy; if you get 4, it is not.&lt;br /&gt;
Here is the code. It might not be in the most convenient format, but here it is:&lt;br /&gt;
&lt;br /&gt;
 Lbl A&lt;br /&gt;
 Prompt J&lt;br /&gt;
 Goto B&lt;br /&gt;
 Lbl B&lt;br /&gt;
 If J&amp;gt;999:Goto A&lt;br /&gt;
 If 1000&amp;gt;J&amp;gt;99:Goto C&lt;br /&gt;
 If 100&amp;gt;J&amp;gt;9:Goto D&lt;br /&gt;
 If 10&amp;gt;J&amp;gt;0 Goto E&lt;br /&gt;
&lt;br /&gt;
Here&amp;#039;s where things get complicated. I&amp;#039;ll try to explain in words what the code is. The explanation is after the // on each line, so don&amp;#039;t put it in the actual program.&lt;br /&gt;
&lt;br /&gt;
 Lbl C&lt;br /&gt;
 (J/100)→K //To isolate each digit, I first divided the number by 100 (Ex. 123 becomes 1.23)&lt;br /&gt;
 iPart(K)→T //Then, I took the integer part, which was formerly the hundreds digit. (Ex. 1.23 becomes 1)&lt;br /&gt;
 (K-T)→O // Next, I subtracted the iPart from the full number, so that I had only 2 digits. (Ex. 1.23-1 becomes 0.23)&lt;br /&gt;
 (O*10)→L //And then I multiplied the new number by 10 to get the next digit. (Ex. 0.23 becomes 2.3)&lt;br /&gt;
 iPart(L)→U //(Ex. 2.3 becomes 2)&lt;br /&gt;
 (L-U)→P //(Ex. 2.3-2 becomes 0.3)&lt;br /&gt;
 (P*10)→V //(Ex. 0.3 becomes 3)&lt;br /&gt;
 (T²+U²+V²)→J&lt;br /&gt;
 Goto B //At the end, we plug the final number back into J and check for the number of digits.&lt;br /&gt;
&lt;br /&gt;
The next piece of code (if J has 2 digits) works the same way.&lt;br /&gt;
&lt;br /&gt;
 Lbl D&lt;br /&gt;
 (J/10)→K&lt;br /&gt;
 iPart(K)→T&lt;br /&gt;
 (K-T)→O&lt;br /&gt;
 (O*10)→U&lt;br /&gt;
 (T²+U²)→J&lt;br /&gt;
 Goto B&lt;br /&gt;
&lt;br /&gt;
The last part (if J has only 1 digit) is a bit different.&lt;br /&gt;
&lt;br /&gt;
 Lbl E&lt;br /&gt;
 If J=1 or 4&lt;br /&gt;
 Then&lt;br /&gt;
 Goto F&lt;br /&gt;
 Else&lt;br /&gt;
 J²→J:Goto B&lt;br /&gt;
 Lbl F&lt;br /&gt;
 If J=1:Disp &amp;quot;HAPPY&amp;quot;&lt;br /&gt;
 If J=4:Disp &amp;quot;NOT HAPPY&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Again, I know it isn&amp;#039;t the most effective method, but it was the first one I came up with. Perhaps, when I am better at coding, I will find a more effective way to do this, but for now, here it is.&lt;br /&gt;
&lt;br /&gt;
Have fun trying out numbers![[Category:TI-BASIC]]&lt;br /&gt;
[[Category:TIBD]]&lt;/div&gt;</summary>
		<author><name>Maintenance script</name></author>
	</entry>
</feed>