OFFSET
1,1
COMMENTS
This sequence was inspired by a puzzle from David K. Butler.
LINKS
Ben Weiss, Multiples of 11
FORMULA
a(n) = a(n - 18) * 10^22 + (a(n - 18) mod 100) * 101010101010101010101.
PROG
(Objective-C)
int main(int argc, const char * argv[]) {
// Search positive integers for solutions, up to 10^20.
for (int length = 1; length < 20; ++length) {
for (int a = 0; a <= 9; ++a) {
int b = 9 - a;
// Test number abababab... with length 'length'
int a_mod_11 = (a * ((length + 1) / 2)) % 11;
int b_mod_11 = (b * ((length ) / 2)) % 11;
int a_add = (b_mod_11 - a_mod_11 + 11) % 11;
if (a + a_add == 10) {
uint64_t num = 0;
uint64_t dec = 1;
for (int d = 0; d < length; ++d) {
num += ((d & 1) ? b : a) * dec;
dec *= 10;
}
NSLog(@"Found solution: %llu", num);
}
}
}
return 0;
}
CROSSREFS
KEYWORD
base,nonn
AUTHOR
Ben Weiss, May 15 2022
STATUS
approved