I was looking at The On-Line Encyclopedia of Integer Sequences when I ran across sequence A247809, which is described as “numbers in decimal representation with distinct digits, such that in Norwegian and Swedish their digits are in alphabetic order.”
July 18, 2019: I think sequence A247809 is wrong.
The “wrong” alphabetical order has: 8=åtta, 1=en/ett, 5=fem, 4=fyra, 0=noll, 6=sex, 7=sju, 9=tio, 2=två, 3=tre or 8, 1, 5, 4, 0, 6, 7, 9, 2, 3.
The “wrong” sequence is: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 13, 14, 15, 16, 17, 19, 23, 40, 42, 43, 46, 47, 49, 50, 52, 53, 54, 56, 57, 59, 62, 63, 67, 69, 72, 73, 79, 80, 81, 82, 83, 84, 85, 86, 87, 89, 92, 93, 102, 103, 106, 107, 109, 123, 140, 142, 143, 146, 147, 149, 150, 152
The word tio (10) should probably be nio (9).1 2
The names are sorted using English sorting rules. In Swedish, the letter Å/å, like in åtta (8), comes after z. Swedish alphabetical order is a, …, z, å, ä, ö. Using Swedish sorting rules and nio for 9, the sequence for 0-9 would be 1, 5, 4, 9, 0, 6, 7, 3, 2, 8.3 4
Wrong Order | 8 | 1 | 5 | 4 | 0 | 6 | 7 | 9 | 2 | 3 |
Correct Order | 1 | 5 | 4 | 9 | 0 | 6 | 7 | 3 | 2 | 8 |
I doubt that the sequence has any value in real life, but it looked like a fun sequence. It would be great to use in an answer for questions like, “What is the next number in this sequence: 19, 22, 28, 32, 33, 38, 40, __?” (The answer is 42. The sequence is Swedish numbers where the digits are in alphabetical order.)
To run the program, you set up the parameters using these lines:
number_base = 2;
digits_order = digits_swedish;
language_name = “swedish”;
upper_limit
is the upper limit for the list of numbers. For example, when set to 100, the list will contain number from 0 to 100 inclusive.
number_base
should be fairly obvious; it’s the base-n for the numbers. For example, when set to two, the list will contain binary numbers.
digits_order
is where you set the language you want to use. See below for extending the program to do other languages.
language_name
is used for creating a file name for the output. For example, when upper_limit
is set to 100, number_base
is set to 2, and language_name
is set to "swedish"
it produces a file name like numbers-with-digits-in-alphabetical-order_swedish_0-100_base-2.txt
.
\(\qquad\)
/*
* Set up parameters.
*/
\(\qquad\)
upper_limit = 100;
number_base = 2;
digits_order = digits_swedish;
language_name = “swedish”;
\(\qquad\)
output_file = Strprintf(“numbers-with-digits-in-alphabetical-order_%s_0-%d_base-%d.txt”, language_name, upper_limit, number_base);
\(\qquad\)
/*
* digits_alphabetical(x)
*/
\(\qquad\)
digits_alphabetical(x) = {
\(\qquad\)my (
\(\qquad\)\(\qquad\)digs = digits(x, number_base),
\(\qquad\)\(\qquad\)first = -1,
\(\qquad\)\(\qquad\)second = -1
\(\qquad\));
\(\qquad\)
\(\qquad\)for (y = 1, #digs – 1,
\(\qquad\)\(\qquad\)for (z = 1, #digits_order, if (digs[y] == digits_order[z], first = z));
\(\qquad\)\(\qquad\)for (z = 1, #digits_order, if (digs[y + 1] == digits_order[z], second = z));
\(\qquad\)\(\qquad\)if (first > second, return (-1))
\(\qquad\));
\(\qquad\)
\(\qquad\)return (x)
}
\(\qquad\)
/*
* Main routine.
*/
{
for (x = 0, upper_limit,
\(\qquad\)if (digits_alphabetical(x) != -1,
\(\qquad\)\(\qquad\)my (z = “”);
\(\qquad\)
\(\qquad\)\(\qquad\)\\ Print to the screen so we can see something happening.
\(\qquad\)\(\qquad\)print1(x, “, “);
\(\qquad\)
\(\qquad\)\(\qquad\)\\ Build the base-n number from the array.
\(\qquad\)\(\qquad\)base_num = digits(x, number_base);
\(\qquad\)
\(\qquad\)for (y = 1, #base_num, z = concat(z, base_num[y]));
\(\qquad\)
\(\qquad\)\(\qquad\)\\ If x == 0, adjust so we get something to print.
\(\qquad\)\(\qquad\)if (x == 0, z = 0);
\(\qquad\)
\(\qquad\)\(\qquad\)\\ If you want to print out the decimal number only, use this next line.
\(\qquad\)\(\qquad\)\\ write1(output_file, x, “, “);
\(\qquad\)
\(\qquad\)\(\qquad\)\\ If you want to print out the base-n number only, use this next line.
\(\qquad\)\(\qquad\)\\ write1(output_file, z, “, “)
\(\qquad\)
\(\qquad\)\(\qquad\)\\ If you want to print out the decimal number and the base-n number,
\(\qquad\)\(\qquad\)\\ use this next line.
\(\qquad\)\(\qquad\)write1(output_file, x, ” (“, z, “), “);
\(\qquad\))
)
}
If you want to extend the program to handle other languages, you can add lines like these.
digits_albanian = [2, 6, 4, 9, 1, 5, 7, 8, 3, 0];
digits_amharic = [2, 8, 3, 6, 7, 4, 5, 1, 9, 0];
digits_czech = [4, 9, 2, 1, 0, 8, 5, 7, 6, 3];
digits_danish = [1, 5, 4, 9, 0, 8, 6, 7, 2, 3];
digits_dutch = [8, 1, 3, 9, 0, 2, 4, 5, 6, 7];
digits_english = [8, 5, 4, 9, 1, 7, 6, 3, 2, 0];
digits_finnish = [8, 2, 3, 6, 4, 0, 7, 5, 9, 1];
digits_french = [5, 2, 8, 9, 4, 7, 6, 3, 1, 0];
digits_german = [8, 3, 1, 5, 9, 0, 6, 7, 4, 2];
digits_hausa = [7, 5, 2, 1, 4, 6, 0, 8, 9, 3];
digits_hungarian = [1, 3, 6, 7, 2, 9, 4, 0, 8, 5];
digits_icelandic = [8, 1, 5, 4, 9, 0, 6, 7, 2, 3];
digits_italian = [5, 2, 9, 8, 4, 6, 7, 3, 1, 0];
digits_klingon = [2, 8, 9, 6, 4, 0, 7, 5, 1, 3]; \\ Klingon!
digits_latin = [2, 9, 8, 4, 5, 6, 7, 3, 1, 0];
digits_norwegian = [8, 1, 5, 4, 0, 6, 7, 9, 2, 3]; \\ May be wrong.
digits_polish = [4, 2, 9, 1, 8, 5, 6, 7, 3, 0];
digits_portuguese = [5, 2, 9, 8, 4, 6, 7, 3, 1, 0];
digits_russian = [8, 2, 9, 0, 1, 5, 7, 3, 4, 6];
digits_slovak = [9, 2, 1, 0, 8, 5, 7, 6, 4, 3];
digits_somali = [4, 0, 1, 2, 6, 3, 9, 5, 8, 7];
digits_spanish = [0, 5, 4, 2, 9, 8, 6, 7, 3, 1];
digits_swedish = [1, 5, 4, 9, 0, 6, 7, 3, 2, 8];
digits_turkish = [6, 5, 1, 9, 4, 2, 8, 0, 3, 7];
digits_zulu = [0, 7, 9, 8, 6, 2, 5, 4, 1, 3];
Then change the following lines to your language of choice.
language_name = “swedish”;
There may be more languages here: “Alphabetized Numbers from 0 to 9“. If you speak a language that is not in our collection, please leave a comment below.
Base 2 output [1, 0]:
Base 3 output [1, 0, 2]:
Base 4 output [1, 0, 3, 2]:
Base 5 output [1, 4, 0, 3, 2]:
Base 6 output [1, 5, 4, 0, 3, 2]:
Base 7 output [1, 5, 4, 0, 6, 3, 2]:
Base 8 output [1, 5, 4, 0, 6, 7, 3, 2]:
Base 9 output [1, 5, 4, 0, 6, 7, 3, 2, 8]:
Base 10 output [1, 5, 4, 9, 0, 6, 7, 3, 2, 8]:
Have fun with it and if you find any interesting patterns, let us know in the comments.
Footnotes
- Wikipedia contributors, “List of numbers in various languages: Germanic languages“. Wikipedia.
- Tibor. “Swedish numbers 1-100“. Swedish Language Blog.
- Swedish speaker (not me).
- Wikipedia contributors. “Swedish alphabet“. Wikipedia.