login
a(n) is the least m > n, such that every letter, with repetition, that occurs in the English name of n also occurs in the English name of m.
4

%I #17 Apr 29 2018 03:45:10

%S 14,21,13,14,25,16,17,18,19,13,111,112,37,74,57,67,77,78,79,21,120,

%T 122,122,124,125,126,127,128,125,31,125,128,132,134,135,136,137,138,

%U 135,41,124,124,124,144,145,64,74,148,94,51,145,152,152,154,155,156,157,158,155,61

%N a(n) is the least m > n, such that every letter, with repetition, that occurs in the English name of n also occurs in the English name of m.

%H Altug Alkan, <a href="/A303475/b303475.txt">Table of n, a(n) for n = 1..10000</a>

%e a(2)=21 because 2 is two, and 21 is twenty-one, where all letters of two appear in twenty-one, and this does not happen before 21.

%t in[n_]:=IntegerName[n,"Words"];

%t ch[n_]:=Characters[StringReplace[IntegerName[n,"Words"],{"-"->""," "->""}]];

%t f[n_]:=Module[{m=n+1},While[Complement[ch[n],ch[m]]!={}||

%t Union[Select[Table[Count[ch[m],ch[n][[i]]]-Count[ch[n],ch[n][[i]]],{i,1,Length[ch[n]]}],#<0&]]!={},m++];m];

%t Array[f,60] (* _Ivan N. Ianakiev_, Apr 26 2018 *)

%o (PARI)

%o v1 = ["one", "two", "three", "four", "five", "six", "seven", "eight", "nine"];

%o v2 = ["eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen"];

%o v3 = ["ten", "twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety"];

%o conv(n) = {if (n >= 10^12, error("too big for this program"));

%o if (n >= 10^9, return (concat(concat(conv(n\10^6), "billion"), conv(n % 10^9))));

%o if (n >= 10^6, return (concat(concat(conv(n\10^6), "million"), conv(n % 10^6))));

%o if (n >= 10^3, return (concat(concat(conv(n\10^3), "thousand"), conv(n % 10^3))));

%o if (n >= 10^2, return (concat(concat(conv(n\100), "hundred"), conv(n % 100))));

%o if (n >= 20, return (concat(v3[n\10], conv(n%10))););

%o if (n >= 10, if (n==10, return(v3[n\10]), return(v2[n % 10])););

%o if (n, return(v1[n]), return (""));

%o }

%o mycmp(sa, sb) = {my(vsa = Vec(sa), vsb = Vec(sb), vsas = vecsort(vsa,,8)); for (i=1, #vsas, if (#select(x->x==vsas[i], vsb) < #select(x->x==vsas[i], vsa), return (0));); return (1);}

%o a(n) = {my(m = n+1, sn = conv(n), sm = conv(m)); while(! mycmp(sn, sm), m++; sm = conv(m)); m;}

%Y Cf. A303380.

%K nonn,word,look

%O 1,1

%A _Michel Marcus_, Apr 24 2018