%I #35 Aug 29 2024 16:28:56
%S 4,5,19,55,271,1889,10529,59777,101249,406783,6581249,12164095,
%T 65071999,652963841,6548416001,13858918399,145046192129,75389157377,
%U 943344975871,23114453401601,108772434771967,101249475018751,551785225781249,9740041658826751,136182187711004671,4560483868737535
%N a(n) = smallest number k such that k-1 and k+1 both have exactly n prime divisors (counted with multiplicity).
%C Similar to A154598, where k is restricted to primes.
%C m=2*a(n) is the least number m such that m-2 and m+2 have exactly n+1 prime factors, counted with multiplicity. - _Hugo Pfoertner_, Apr 02 2024
%H David A. Corneth, <a href="/A154704/b154704.txt">Table of n, a(n) for n = 1..36</a>
%H David A. Corneth, <a href="/A154704/a154704.gp.txt">Upper bounds on a(n) for n = 1..89</a>
%F a(n) = 2*A115186(n-1) + 1 for n > 1. - _Hugo Pfoertner_, Apr 02 2024
%e For k = 4, k-1 = 3 and k+1 = 5 (twin primes) both have one factor and 4 is the smallest such number.
%e For k = 55, k-1 = 54 = 2*3*3*3 and k+1 = 56 = 2*2*2*7 both have four factors and 55 is the smallest such number.
%e For k = 59777, k-1 = 59776 = 2*2*2*2*2*2*2*467 and k+1 = 59778 = 2*3*3*3*3*3*3*41 both have eight factors and 59777 is the smallest such number.
%t a[n_]:=Module[{k=2}, While[PrimeOmega[k-1]!=n || PrimeOmega[k+1]!=n, k++]; k]; Array[a,26] (* _Stefano Spezia_, Apr 02 2024 *)
%t Flatten[Table[Position[Partition[PrimeOmega[Range[410000]],3,1],_?(#[[1]]==#[[3]]==n&),1,1],{n,10}]]+1//Quiet (* The program generates the first ten terms of the sequence. *) (* _Harvey P. Dale_, Jul 21 2024 *)
%t Table[SequencePosition[PrimeOmega[Range[410000]],{n,_,n},1],{n,10}][[;;,1,1]]+1 (* The program generates the first ten terms of the sequence. *) (* _Harvey P. Dale_, Aug 29 2024 *)
%o (Magma) S:=[]; for n:=1 to 10 do k:=3; while not &+[ f[2]: f in Factorization(k-1) ] eq n or not &+[ f[2]: f in Factorization(k+1) ] eq n do k+:=1; end while; Append(~S, k); end for; S;
%o (PARI)
%o generate(A, B, n, k) = A=max(A, 2^n); (f(m, p, n) = my(list=List()); if(n==1, forprime(q=max(p, ceil(A/m)), B\m, if(bigomega(m*q+2) == k, listput(list, m*q+1))), forprime(q=p, sqrtnint(B\m, n), list=concat(list, f(m*q, q, n-1)))); list); vecsort(Vec(f(1, 2, n)));
%o a(n) = my(x=2^n, y=2*x); while(1, my(v=generate(x, y, n, n)); if(#v >= 1, return(v[1])); x=y+1; y=2*x); \\ _Daniel Suteu_, Aug 12 2023
%Y Cf. A115186, A154598.
%Y Cf. A001222 (number of prime divisors of n).
%K nonn
%O 1,1
%A _Klaus Brockhaus_, Jan 14 2009, Jan 15 2009
%E a(15)-a(23) from _Donovan Johnson_, Jan 21 2009
%E a(24)-a(26) from _Daniel Suteu_, Aug 12 2023