;Task &nbsp; (in three parts):


;Part 1
Write a procedure (say <math>\mathit{co9}(x)</math>) which implements [http://mathforum.org/library/drmath/view/55926.html Casting Out Nines] as described by returning the checksum for <math>x</math>. Demonstrate the procedure using the examples given there, or others you may consider lucky.

;Part 2
Notwithstanding past Intel microcode errors, checking computer calculations like this would not be sensible. To find a computer use for your procedure:
: Consider the statement "318682 is 101558 + 217124 and squared is 101558217124" (see: [[Kaprekar numbers#Casting Out Nines (fast)]]).
: note that <math>318682</math> has the same checksum as (<math>101558 + 217124</math>);
: note that <math>101558217124</math> has the same checksum as (<math>101558 + 217124</math>) because for a Kaprekar they are made up of the same digits (sometimes with extra zeroes);
: note that this implies that for Kaprekar numbers the checksum of <math>k</math> equals the checksum of <math>k^2</math>.

Demonstrate that your procedure can be used to generate or filter a range of numbers with the property <math>\mathit{co9}(k) = \mathit{co9}(k^2)</math> and show that this subset is a small proportion of the range and contains all the Kaprekar in the range.

;Part 3
Considering [http://mathworld.wolfram.com/CastingOutNines.html this MathWorld page], produce a efficient algorithm based on the more mathematical treatment of Casting Out Nines, and realizing:
: <math>\mathit{co9}(x)</math> is the residual of <math>x</math> mod <math>9</math>;
: the procedure can be extended to bases other than 9.

Demonstrate your algorithm by generating or filtering a range of numbers with the property <math>k%(\mathit{Base}-1) == (k^2)%(\mathit{Base}-1)</math> and show that this subset is a small proportion of the range and contains all the Kaprekar in the range.
<br>
;related tasks
* [[First perfect square in base N with N unique digits]]
* [[Kaprekar numbers]]
<br>
