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.

A248651 a(n) is the smallest number greater than a(n-1) such that in a(1) through a(n) no digit occurs more than once more than any other digit, starting with a(1) = 1.

This page as a plain text file.
%I A248651 #34 Aug 20 2020 21:01:27
%S A248651 1,2,3,4,5,6,7,8,9,10,20,34,56,78,79,80,91,234,256,301,456,789,790,
%T A248651 812,3456,3457,6012,6089,7123,8459,8460,9123,9157,20345,20678,31456,
%U A248651 31789,40256,40789,51236,51789,60234,60789,71234,71589,80234,80569,91234,91567,203456,203478,516789,516790,518234,602347,602389,714589,714590,716238,802345,802369,914567,914568,917023,2034567
%N A248651 a(n) is the smallest number greater than a(n-1) such that in a(1) through a(n) no digit occurs more than once more than any other digit, starting with a(1) = 1.
%C A248651 Starting with 1, instead of 0 as in A095204, means 0 doesn't appear until a(10)=10, hence a(11)=20, not 23.
%H A248651 Jeb Adams, <a href="/A248651/b248651.txt">Table of n, a(n) for n = 1..300</a>
%o A248651 (R)
%o A248651 # Script (R, using base only) to build values in the sequence defined
%o A248651 # in A248651:
%o A248651 # a(n) is the smallest number greater than a(n-1) such that no
%o A248651 # digit appears in the listing of all terms more than one time
%o A248651 # more than any other digit in the listing, with a(1) = 1.
%o A248651 digits <- c(0:9) #vector of the digits
%o A248651 digitCounts <- rep(0L,10) #vector for digit count tracking
%o A248651 A <- c() #vector of entries
%o A248651 A[1] <- 1L #first entry
%o A248651 failed <- 1L #failed entry
%o A248651 digitCounts[2] = 1L #impact of first entry on digitCounts
%o A248651 # Build a function that turns a number into a vector of its
%o A248651 # component digits
%o A248651 digits <- function(x) {
%o A248651   if(length(x) > 1 ) {
%o A248651     lapply(x, digits)
%o A248651   } else {
%o A248651     n <- floor(log10(x))+1L
%o A248651     rev( x %/% 10^seq(0, length.out=n) %% 10 )
%o A248651   }
%o A248651 }
%o A248651 # Engine for testing digits, runs VERY SLOW, but checks every integer.
%o A248651 # I welcome improvements, note that it respects incrementing
%o A248651 # more than one digit at a time if that makes sense.
%o A248651 while (length(A) < 300) {
%o A248651   i <- max(failed, max(A)) + 1
%o A248651   newCounts <- digitCounts
%o A248651   digitList <- digits(i)
%o A248651   for (j in digitList) {
%o A248651     newCounts[j + 1] <- newCounts[j + 1] + 1
%o A248651   }
%o A248651   if (max(newCounts) - min(newCounts) > 1) {
%o A248651        failed <- i } else {
%o A248651         digitCounts <- newCounts
%o A248651         A <- c(A,as.integer(i))
%o A248651       }
%o A248651 } # _Jeb Adams_, Jul 17 2020
%Y A248651 Same definition of A095204, but starting with 1. Similar to A120125.
%K A248651 nonn,base
%O A248651 1,2
%A A248651 _Jeb Adams_, Oct 10 2014
%E A248651 Terms a(15) and beyond corrected by _Jeb Adams_, May 01 2020