cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A262222 Decimal representations of hexadecimal numbers that can be misinterpreted as decimal numbers in scientific E notation.

This page as a plain text file.
%I A262222 #48 Sep 29 2023 10:19:55
%S A262222 480,481,482,483,484,485,486,487,488,489,736,737,738,739,740,741,742,
%T A262222 743,744,745,992,993,994,995,996,997,998,999,1000,1001,1248,1249,1250,
%U A262222 1251,1252,1253,1254,1255,1256,1257,1504,1505,1506,1507,1508,1509,1510,1511
%N A262222 Decimal representations of hexadecimal numbers that can be misinterpreted as decimal numbers in scientific E notation.
%C A262222 Hexadecimal numbers containing no alpha digits other than a single "e", where the "e" is not the first or last digit (e.g., 3e12), may be misinterpreted as numbers in scientific E notation.
%C A262222 These numbers are especially troublesome when importing hexadecimal numbers from CSV files into Microsoft Excel.
%C A262222 These numbers can be written as 16^(i+1)a + 14*16^i + b where a and b are members of A102489 with a>0, b<16^i and i>0.
%C A262222 Numbers whose hexadecimal representation matches the regular expression [1-9][0-9]*e[0-9]+. - _Eric M. Schmidt_, Sep 28 2023
%H A262222 Christian Perfect, <a href="/A262222/b262222.txt">Table of n, a(n) for n = 1..99999</a>
%H A262222 Microsoft Community, <a href="http://answers.microsoft.com/en-us/office/forum/office_2007-excel/disabling-scientific-notation/943b8103-8c50-451d-8037-c697422e2307">Unable to disable scientific notation in Microsoft Excel</a>.
%H A262222 Wikipedia, <a href="https://en.wikipedia.org/wiki/Scientific_notation#E_notation">Scientific E notation</a>.
%e A262222 480_10 = 1e0_16 and 1e0 = 1 in E notation.
%e A262222 739_10 = 2e3_16 and 2e3 = 2000_10 in E notation.
%o A262222 (C++)
%o A262222 #include <iostream>
%o A262222 #include <string>
%o A262222 using namespace std;
%o A262222 int main()
%o A262222 {
%o A262222   int n = 0;                  //integer to check
%o A262222   char hexRepresentation[12];
%o A262222   for (int i = 0; i < 100;)   //integers found (first 100)
%o A262222   {
%o A262222     sprintf(hexRepresentation, "%x", n);              //get hex representation
%o A262222     char* foundE = strchr(hexRepresentation, 'e');    //look for letter e
%o A262222     if (foundE != NULL &&                             //at least one e
%o A262222     hexRepresentation != foundE &&                    //not the first digit
%o A262222     strpbrk(hexRepresentation, "abcdef") == foundE && //e is not first alpha
%o A262222     strlen(foundE) != 1 &&                            //something after the e
%o A262222     strpbrk(foundE + sizeof(char), "abcdef") == NULL) //no alpha after the e
%o A262222     {
%o A262222       cout << n << "\n";    //output n
%o A262222       i++;                  //discovered an integer
%o A262222     }
%o A262222     n++;                    //check next value
%o A262222   }
%o A262222 }
%o A262222 (Python)
%o A262222 from itertools import count,product
%o A262222 # every string of d characters with exactly one 'e' in it, and all the other characters digits 0-9, in ascending lexicographic order
%o A262222 def mids(d):
%o A262222     if d<1:
%o A262222         raise Exception("d<1")
%o A262222     if d==1:
%o A262222         yield 'e'
%o A262222         return
%o A262222     for i in range(0,10):
%o A262222         for m in mids(d-1):
%o A262222             yield str(i)+m
%o A262222     for i in range(10**(d-1)):
%o A262222         yield 'e'+str(i).zfill(d-1)
%o A262222 def a_generator():
%o A262222     for d in count(1):
%o A262222         for start in range(1,10): # for each leading digit 1-9
%o A262222             for mid in mids(d): # for all possible middles made of d characters, containing exactly one 'e'
%o A262222                 for end in range(10): #for each possible final digit, 0-9
%o A262222                     s = '{}{}{}'.format(start,''.join(mid),end)
%o A262222                     i = int(s,16)
%o A262222                     yield i
%o A262222 a262222 = a_generator()
%o A262222 [next(a262222) for _ in range(48)] # _Christian Perfect_, Oct 20 2015
%o A262222 (C)
%o A262222 #include <stdbool.h>
%o A262222 #define DIGIT_E 14
%o A262222 bool isA262222(int k)
%o A262222 {
%o A262222     if (k <= 0 || k % 16 == DIGIT_E) return false;
%o A262222     bool foundE = false;
%o A262222     int digit;
%o A262222     while (k > 0) {
%o A262222         digit = k % 16;
%o A262222         if (digit == DIGIT_E) {
%o A262222             if (foundE) return false;
%o A262222             foundE = true;
%o A262222         }
%o A262222         else if (digit > 9) return false;
%o A262222         k /= 16;
%o A262222     }
%o A262222     return foundE && digit != DIGIT_E;
%o A262222 } // _Eric M. Schmidt_, Sep 28 2023
%Y A262222 A subset of A102490.
%K A262222 nonn,base
%O A262222 1,1
%A A262222 _Adam J.T. Partridge_, Sep 16 2015