Input: Positive integer =
Output: , =
(1) i = 0.
(2) While (k > 0) do
(2.1) if (k is odd) then
(2.2)  = 2 − (k mod 4);
(2.3) else
(2.4)  = 0;
(2.5) k = ( )/2;
(2.6) ;
(3)Return (k).
Algorithm 1: NAF of a positive integer .