# A bevy of ones

Take any positive integer d that is not a multiple of 2 or 5.

Then there is some integer k such that d × k has only 1’s in its decimal representation.

For example, take d = 13.

We have 13 × 8457 = 111111.

Or if we take d = 27, 27 × 4115226337448559670781893 = 111111111111111111111111111.

If d is not a multiple of 2 or 5, then there is some number made up of only 1’s that is divisible by d.

And in fact, the number of 1’s is no more than d.

This theorem generalizes to any integer base b > 1.

If d is relatively prime to b, then there is a base b number with d or fewer “digits” which is divisible by d [1].

The following Python code allows us to find the number k such that d × k has only 1’s in its base b representation, provided k is relatively prime to b.

It returns the number of 1’s we need to string together to find a multiple of k.

If k shares a factor with b, the code returns 0 because no string of 1’s will ever be divisible by k.

from math import gcd def all_ones(n, b = 10): return sum(b**i for i in range(n)) def find_multiple(k, b = 10): if gcd(k, b) > 1: return 0 for n in range(1, k+1): if all_ones(n, b) % k == 0: return n The two Python functions above default to base 10 if a base isn’t provided.

We could find a multiple of 5 whose hexadecimal representation is all 1’s by calling print(find_multiple(5, 16)) and this tells us that 11111sixteen is a multiple of 5, and in fact 5 × 369dsixteen = 11111sixteen.

[1] Elmer K.

Hayashi.

Factoring Integers Whose Digits Are all Ones.

Mathematics Magazine, Vol.

49, No.

1 (Jan.

, 1976), pp.

19-22.
{"found_math": false, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "url": "http://datascience.sharerecipe.net/2020/08/14/a-bevy-of-ones/", "fetch_time": 1716374794000000000, "content_mime_type": "text/html", "warc_filename": "crawl-data/CC-MAIN-2024-22/segments/1715971058542.48/warc/CC-MAIN-20240522101617-20240522131617-00575.warc.gz", "warc_record_offset": 6180350, "warc_record_length": 7523, "token_count": 476, "char_count": 1603, "score": 3.6875, "int_score": 4, "crawl": "CC-MAIN-2024-22", "snapshot_type": "latest", "language": "en", "language_score": 0.813886821269989, "file_path": "/sailhome/yjruan/project/latent-lm/data/processed/finemath-4plus/finemath-4plus/train-00009-of-00064.parquet"}