Computational Fun with Sturdy and Flimsy Numbers

Authors Trevor Clokie, Thomas F. Lidbetter, Antonio J. Molina Lovett , Jeffrey Shallit , Leon Witzman

Thumbnail PDF


  • Filesize: 0.57 MB
  • 21 pages

Document Identifiers

Author Details

Trevor Clokie
  • University of Waterloo, Canada
Thomas F. Lidbetter
  • University of Waterloo, Canada
Antonio J. Molina Lovett
  • University of Waterloo, Canada
Jeffrey Shallit
  • University of Waterloo, Canada
Leon Witzman
  • University of Waterloo, Canada


We would like to thank Kenneth Stolarsky and the referees for helpful comments.

Cite AsGet BibTex

Trevor Clokie, Thomas F. Lidbetter, Antonio J. Molina Lovett, Jeffrey Shallit, and Leon Witzman. Computational Fun with Sturdy and Flimsy Numbers. In 10th International Conference on Fun with Algorithms (FUN 2021). Leibniz International Proceedings in Informatics (LIPIcs), Volume 157, pp. 10:1-10:21, Schloss Dagstuhl – Leibniz-Zentrum für Informatik (2020)


Following Stolarsky, we say that a natural number n is flimsy in base b if some positive multiple of n has smaller digit sum in base b than n does; otherwise it is sturdy . We develop algorithmic methods for the study of sturdy and flimsy numbers. We provide some criteria for determining whether a number is sturdy. Focusing on the case of base b = 2, we study the computational problem of checking whether a given number is sturdy, giving several algorithms for the problem. We find two additional, previously unknown sturdy primes. We develop a method for determining which numbers with a fixed number of 0’s in binary are flimsy. Finally, we develop a method that allows us to estimate the number of k-flimsy numbers with n bits, and we provide explicit results for k = 3 and k = 5. Our results demonstrate the utility (and fun) of creating algorithms for number theory problems, based on methods of automata theory.

Subject Classification

ACM Subject Classification
  • Theory of computation → Grammars and context-free languages
  • Theory of computation → Dynamic programming
  • sturdy number
  • flimsy number
  • context-free grammar
  • finite automaton
  • enumeration


  • Access Statistics
  • Total Accesses (updated on a weekly basis)
    PDF Downloads


  1. B. Alexeev. Minimal DFAs for testing divisibility. J. Comput. System Sci., 69:235-243, 2004. Google Scholar
  2. A. Asinowski, A. Bacher, C. Banderier, and B. Gittenberger. Analytic combinatorics of lattice paths with forbidden patterns: enumerative aspects. In S. T. Klein et al., editors, LATA 2018, volume 10792 of Lecture Notes in Computer Science, pages 195-206. Springer-Verlag, 2018. Google Scholar
  3. A. Asinowski, A. Bacher, C. Banderier, and B. Gittenberger. Analytic combinatorics of lattice paths with forbidden patterns, the vectorial kernel method, and generating functions for pushdown automata. Algorithmica, 82:386-428, 2020. Google Scholar
  4. C. Banderier and M. Drmota. Coefficients of algebraic functions: formulae and asymptotics. In FPSAC 2013, volume AS of DMTCS Proc., pages 1065-1076. DMTCS, 2013. Google Scholar
  5. C. Banderier and M. Drmota. Formulae and asymptotics for coefficients of algebraic functions. Combin. Prob. Comput., 24:1-53, 2015. Google Scholar
  6. B. Bašić. The existence of n-flimsy numbers in a given base. Ramanujan J., 43:359-369, 2017. Google Scholar
  7. J. Bell, K. Hare, and J. Shallit. When is an automatic set an additive basis? Proc. Amer. Math. Soc. Ser. B, 5:50-63, 2018. Google Scholar
  8. L. H. Y. Chen, H.-K. Hwang, and V. Zacharovas. Distribution of the sum-of-digits function of random integers: a survey. Prob. Surveys, 11:177-236, 2014. Google Scholar
  9. N. Chomsky and M. P. Schützenberger. The algebraic theory of context-free languages. In P. Braffort and D. Hirschberg, editors, Computer Programming and Formal Systems, pages 118-161. North Holland, Amsterdam, 1963. Google Scholar
  10. C. Dartyge, F. Luca, and P. Stănică. On digit sums of multiples of an integer. J. Number Theory, 129:2820-2830, 2009. Google Scholar
  11. C. Elsholtz. Almost all primes have a multiple of small Hamming weight. Bull. Austral. Math. Soc., 94:224-235, 2016. Google Scholar
  12. P. Flajolet and R. Sedgewick. Analytic Combinatorics. Cambridge University Press, 2009. Google Scholar
  13. M. A. Harrison. Introduction to Formal Language Theory. Addison-Wesley, 1978. Google Scholar
  14. H. Hasse. Über die Dichte der Primzahlen p, für die einevorgegebene ganz rationale Zahl a ̸ = 0 von gerader bzw. ungerader Ordnung mod p ist. Math. Annalen, 166:19-23, 1966. Google Scholar
  15. J. E. Hopcroft and J. D. Ullman. Introduction to Automata Theory, Languages, and Computation. Addison-Wesley, 1979. Google Scholar
  16. I. Kátai. Change of the sum of digits by multiplication. Acta Sci. Math. (Szeged), 39:319-328, 1977. Google Scholar
  17. W. Kuich and A. Salomaa. Semirings, Automata, Languages. Springer-Verlag, 1986. Google Scholar
  18. R. W. K. Odoni. A conjecture of Krishnamurthy on decimal periods and some allied problems. J. Number Theory, 13:303-319, 1981. Google Scholar
  19. A. Panholzer. Gröbner bases and the defining polynomial of a context-free grammar generating function. J. Automata, Languages, and Combinatorics, 10:79-97, 2005. Google Scholar
  20. Pavel V. Phedotov. Sum of digits of a multiple of a given number (in Russian), 2002. Available at URL:
  21. V. Pless, P. Solé, and Z. Qian. Cyclic self-dual Z₄-codes. Finite Fields Appl., 3:48-69, 1997. Google Scholar
  22. A. Rajasekaran, J. Shallit, and T. Smith. Additive number theory via automata theory. Theor. Comput. Sys., 64:542-567, 2020. Google Scholar
  23. B. Salvy. gdev package of algolib version 17.0. Available at, 2013.
  24. J. Schmid. The joint distribution of the binary digits of integer multiples. Acta Arith., 43:391-415, 1984. Google Scholar
  25. W. M. Schmidt. The joint distributions of the digits of certain integer s-tuples. In P. Erdős, editor, Studies in Pure Mathematics to the Memory of Paul Turán, pages 605-622. Birkhäuser, 1983. Google Scholar
  26. D. Shanks. Class number, a theory of factorization and genera. In Proc. Sympos. Pure Math., volume 20, pages 415-440, 1969. Google Scholar
  27. N. J. A. Sloane et al. The on-line encyclopedia of integer sequences. Available at, 2019.
  28. K. B. Stolarsky. Integers whose multiples have anomalous digital frequencies. Acta Arith., 38:117-128, 1980/81. Google Scholar
  29. S. S. Wagstaff et al. The Cunningham project. Available at, 2019.
Questions / Remarks / Feedback

Feedback for Dagstuhl Publishing

Thanks for your feedback!

Feedback submitted

Could not send message

Please try again later or send an E-mail