where a,b,c,d are one-figure numbers and
The above algorithm gives the trivial number 0 or the non-trivial number 7641 within 8 steps.
In short,
If you repeat i and ii, you will finally get a fixed number A=7641.
e.g. (Suppose 3982)
A=3982 ---> L=9832, S=2389 L-S = 7443
A=7443 ---> L=7443, S=3447 L-S = 3996
A=3996 ---> L=9963, S=3699 L-S = 6264
A=6264 ---> L=6642, S=2466 L-S = 4176
A=4176 ---> L=7641, S=1467 L-S = 6174
A=6174