reviewed
approved
Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).
reviewed
approved
proposed
reviewed
editing
proposed
<a href="/index/Rec#order_03">Index entries for linear recurrences with constant coefficients</a>, signature (1,1,13,-3).
a(n) = a(n-1) - 3*a(n-2) + 3*a(n-3), for n >= 5.
LinearRecurrence[{1, 1, 13, -3}, {1, 2, 3, 6, 11}, 61]
(Magma) I:=[3, 6, 11]; [1, 2] cat [n le 3 select I[n ] else Self(n-1) +3*Self(n-2) +-3*Self(n-3): n in [1..60]];
@CachedFunction
def A254006(n): return 3^(n/2)*(1 + (-1)^n)/2
def aA358027(n): return (n+1/3) if *( 4*A254006(n<3) else a+ 7*A254006(n-1) +a2*int(n-==0) + 2) +a*int(n==1) - 3 ) # a = A047081
[aA358027(n) for n in (0..60)]
allocated for G. C. Greubel
Expansion of g.f.: (1 + x - 2*x^2 + 2*x^4)/((1-x)*(1-3*x^2)).
1, 2, 3, 6, 11, 20, 35, 62, 107, 188, 323, 566, 971, 1700, 2915, 5102, 8747, 15308, 26243, 45926, 78731, 137780, 236195, 413342, 708587, 1240028, 2125763, 3720086, 6377291, 11160260, 19131875, 33480782, 57395627
0,2
<a href="/index/Rec#order_03">Index entries for linear recurrences with constant coefficients</a>, signature (1,1,1).
a(n) = (1/3)*(2*[n=0] + 2*[n=1] - 3 + 4*A254006(n) + 7*A254006(n-1))).
E.g.f.: (1/3)*( 2 + 2*x - 3*exp(x) + 4*cosh(sqrt(3)*x) + (7/sqrt(3))*sinh(sqrt(3)*x) ).
G.f.: (1 +x -2*x^2 +2*x^4)/((1-x)*(1-3*x^2)). - Clark Kimberling, Oct 31 2022
LinearRecurrence[{1, 1, 1}, {1, 2, 3}, 61]
(Magma) [n le 3 select n else Self(n-1) +Self(n-2) +Self(n-3): n in [1..60]];
(SageMath)
@CachedFunction
def a(n): return (n+1) if (n<3) else a(n-1) +a(n-2) +a(n-3) # a = A047081
[a(n) for n in (0..60)]
allocated
easy,nonn
G. C. Greubel, Oct 31 2022
approved
editing
allocated for G. C. Greubel
recycled
allocated
reviewed
approved
proposed
reviewed
editing
proposed
Distinct digital permutations of the first m terms of A033307 arranged lexicographically, for m = 1, 2, 3, ...
1, 12, 21, 123, 132, 213, 231, 312, 321, 1234, 1243, 1324, 1342, 1423, 1432, 2134, 2143, 2314, 2341, 2413, 2431, 3124, 3142, 3214, 3241, 3412, 3421, 4123, 4132, 4213, 4231, 4312, 4321, 12345, 12354, 12435, 12453, 12534, 12543, 13245, 13254, 13425, 13452, 13524
1,2
Permutations starting with the digit 0 are omitted.
(Python)
from itertools import islice, count
from sympy.utilities.iterables import multiset_permutations as mp
def bgen(): yield from (c for n in count(1) for c in str(n))
def agen():
s, g = "", bgen()
while True:
s += next(g)
yield from (int("".join(p)) for p in mp(s) if p[0] != "0")
print(list(islice(agen(), 50))) # Michael S. Branicky, Oct 25 2022
(Python)
def toint(l):
a=0; L=len(l); p=1
for i in range(L-1, -1, -1):
a+=l[i]*p; p*=10
return a
def f(n):
tot=0; L=0; ans=[]
while 1:
L+=1; cont=0; cur=1; d=[]
while cont<L:
cur1=cur; cur+=1
cur1=str(cur1)
while cur1:
lc=cur1[0]; cur1=cur1[1:]; d.append(int(lc)); cont+=1
if cont==L:
break
d=sorted(d)
if d[0]==0:
d.remove(1);
d=[1]+d
while 1:
ans.append(toint([*d])); tot+=1
if tot==n:
return ans
j=L-2
while j>-1:
if d[j]<d[j+1]:
for k in range(j+1, L):
if k==L-1:
d[j], d[k]=d[k], d[j]; d=d[:j+1]+sorted(d[j+1:])
elif d[k+1]<=d[j]:
d[j], d[k]=d[k], d[j]; d=d[:j+1]+sorted(d[j+1:]); break
break
j-=1
if j==-1:
break
print(f(10000)) # Michele Botta, Oct 25 2022
easy,nonn,base,changed
recycled
Michele Botta and Marco Ripà, Oct 25 2022
proposed
editing