NestWhile
[f, expr, test]True
.NestWhile
[f, expr, test, m]NestWhile
[f, expr, test, All]Divide by 2 until the result is no longer an integer:
NestWhile[#/2&, 10000, IntegerQ]
Calculate the sum of third powers of the digits of a number until the
same result appears twice:
NestWhile[Total[IntegerDigits[#]^3] &, 5, UnsameQ, All]
Print the intermediate results:
NestWhile[Total[IntegerDigits[#]^3] &, 5, (Print[{##}]; UnsameQ[##]) &, All]