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.

Showing 1-7 of 7 results.

A064989 Multiplicative with a(2^e) = 1 and a(p^e) = prevprime(p)^e for odd primes p.

Original entry on oeis.org

1, 1, 2, 1, 3, 2, 5, 1, 4, 3, 7, 2, 11, 5, 6, 1, 13, 4, 17, 3, 10, 7, 19, 2, 9, 11, 8, 5, 23, 6, 29, 1, 14, 13, 15, 4, 31, 17, 22, 3, 37, 10, 41, 7, 12, 19, 43, 2, 25, 9, 26, 11, 47, 8, 21, 5, 34, 23, 53, 6, 59, 29, 20, 1, 33, 14, 61, 13, 38, 15, 67, 4, 71, 31, 18, 17, 35, 22, 73, 3, 16
Offset: 1

Views

Author

Vladeta Jovovic, Oct 30 2001

Keywords

Comments

From Antti Karttunen, May 12 2014: (Start)
a(A003961(n)) = n for all n. [This is a left inverse function for the injection A003961.]
Bisections are A064216 (the terms at odd indices) and A064989 itself (the terms at even indices), i.e., a(2n) = a(n) for all n.
(End)
From Antti Karttunen, Dec 18-21 2014: (Start)
When n represents an unordered integer partition via the indices of primes present in its prime factorization (for n >= 2, n corresponds to the partition given as the n-th row of A112798) this operation subtracts one from each part. If n is of the form 2^k (a partition having just k 1's as its parts) the result is an empty partition (which is encoded by 1, having an "empty" factorization).
For all odd numbers n >= 3, a(n) tells which number is located immediately above n in square array A246278. Cf. also A246277.
(End)
Alternatively, if numbers are represented as the multiset of indices of prime factors with multiplicity, this operation subtracts 1 from each element and discards the 0's. - M. F. Hasler, Dec 29 2014

Examples

			a(20) = a(2^2*5) = a(2^2)*a(5) = prevprime(5) = 3.
		

Crossrefs

Cf. A064216 (odd bisection), A003961 (inverse), A151799.
Other sequences whose definition involve or are some other way related with this sequence: A105560, A108951, A118306, A122111, A156552, A163511, A200746, A241909, A243070, A243071, A243072, A243073, A244319, A245605, A245607, A246165, A246266, A246268, A246277, A246278, A246361, A246362, A246371, A246372, A246373, A246374, A246376, A246380, A246675, A246682, A249745, A250470.
Similar prime-shifts towards smaller numbers: A252461, A252462, A252463.

Programs

  • Haskell
    a064989 1 = 1
    a064989 n = product $ map (a008578 . a049084) $ a027746_row n
    -- Reinhard Zumkeller, Apr 09 2012
    (MIT/GNU Scheme, with Aubrey Jaffer's SLIB Scheme library)
    (require 'factor)
    (define (A064989 n) (if (= 1 n) n (apply * (map (lambda (k) (if (zero? k) 1 (A000040 k))) (map -1+ (map A049084 (factor n)))))))
    ;; Antti Karttunen, May 12 2014
    (definec (A064989 n) (if (= 1 n) n (* (A008578 (A055396 n)) (A064989 (A032742 n))))) ;; One based on given recurrence and utilizing memoizing definec-macro.
    (definec (A064989 n) (cond ((= 1 n) n) ((even? n) (A064989 (/ n 2))) (else (A163511 (/ (- (A243071 n) 1) 2))))) ;; Corresponds to one of the alternative formulas, but is very unpractical way to compute this sequence. - Antti Karttunen, Dec 18 2014
    
  • Maple
    q:= proc(p) prevprime(p) end proc: q(2):= 1:
    [seq(mul(q(f[1])^f[2], f = ifactors(n)[2]), n = 1 .. 1000)]; # Robert Israel, Dec 21 2014
  • Mathematica
    Table[Times @@ Power[Which[# == 1, 1, # == 2, 1, True, NextPrime[#, -1]] & /@ First@ #, Last@ #] &@ Transpose@ FactorInteger@ n, {n, 81}] (* Michael De Vlieger, Jan 04 2016 *)
  • PARI
    { for (n=1, 1000, f=factor(n)~; a=1; j=1; if (n>1 && f[1, 1]==2, j=2); for (i=j, length(f), a*=precprime(f[1, i] - 1)^f[2, i]); write("b064989.txt", n, " ", a) ) } \\ Harry J. Smith, Oct 02 2009
    
  • PARI
    a(n) = {my(f = factor(n)); for (i=1, #f~, if ((p=f[i,1]) % 2, f[i,1] = precprime(p-1), f[i,1] = 1);); factorback(f);} \\ Michel Marcus, Dec 18 2014
    
  • PARI
    A064989(n)=factorback(Mat(apply(t->[max(precprime(t[1]-1),1),t[2]],Vec(factor(n)~))~)) \\ M. F. Hasler, Dec 29 2014
    
  • Python
    from sympy import factorint, prevprime
    from operator import mul
    from functools import reduce
    def a(n):
        f=factorint(n)
        return 1 if n==1 else reduce(mul, [1 if i==2 else prevprime(i)**f[i] for i in f])
    print([a(n) for n in range(1, 101)]) # Indranil Ghosh, Jun 15 2017
    
  • Python
    from math import prod
    from sympy import prevprime, factorint
    def A064989(n): return prod(prevprime(p)**e for p, e in  factorint(n>>(~n&n-1).bit_length()).items()) # Chai Wah Wu, Jan 05 2023

Formula

From Antti Karttunen, Dec 18 2014: (Start)
If n = product A000040(k)^e(k) then a(n) = product A008578(k)^e(k) [where A000040(n) gives the n-th prime, and A008578(n) gives 1 for 1 and otherwise the (n-1)-th prime].
a(1) = 1; for n > 1, a(n) = A008578(A055396(n)) * a(A032742(n)). [Above formula represented as a recurrence. Cf. A252461.]
a(1) = 1; for n > 1, a(n) = A008578(A061395(n)) * a(A052126(n)). [Compare to the formula of A252462.]
This prime-shift operation is used in the definitions of many other sequences, thus it can be expressed in many alternative ways:
a(n) = A200746(n) / n.
a(n) = A242424(n) / A105560(n).
a(n) = A122111(A122111(n)/A105560(n)) = A122111(A052126(A122111(n))). [In A112798-partition context: conjugate, remove the largest part (the largest prime factor), and conjugate again.]
a(1) = 1; for n > 1, a(2n) = a(n), a(2n+1) = A163511((A243071(2n+1)-1) / 2).
a(n) = A249818(A250470(A249817(n))). [A250470 is an analogous operation for "going one step up" in the square array A083221 (A083140).]
(End)
Product_{k=1..n} a(k) = n! / A307035(n). - Vaclav Kotesovec, Mar 21 2019
Sum_{k=1..n} a(k) ~ c * n^2, where c = (1/2) * Product_{p prime} ((p^2-p)/(p^2-q(p))) = 0.220703928... , where q(p) = prevprime(p) (A151799) if p > 2 and q(2) = 1. - Amiram Eldar, Nov 18 2022

A246377 Permutation of natural numbers: a(1) = 1, a(p_n) = 2*a(n)+1, a(c_n) = 2*a(n), where p_n = n-th prime = A000040(n), c_n = n-th composite number = A002808(n).

Original entry on oeis.org

1, 3, 7, 2, 15, 6, 5, 14, 4, 30, 31, 12, 13, 10, 28, 8, 11, 60, 29, 62, 24, 26, 9, 20, 56, 16, 22, 120, 61, 58, 63, 124, 48, 52, 18, 40, 25, 112, 32, 44, 27, 240, 21, 122, 116, 126, 57, 248, 96, 104, 36, 80, 17, 50, 224, 64, 88, 54, 23, 480, 121, 42, 244, 232, 252, 114, 59, 496, 192, 208, 125, 72, 49, 160, 34, 100
Offset: 1

Views

Author

Antti Karttunen, Aug 27 2014

Keywords

Comments

This permutation is otherwise like Katarzyna Matylla's A135141, except that the role of even and odd numbers (or alternatively: primes and composites) has been swapped.
Because 2 is the only even prime, it implies that, apart from a(2)=3, odd numbers occur in odd positions only (along with many even numbers that also occur in odd positions).
This also implies that for each odd composite (A071904) there exists a separate infinite cycle in this permutation, apart from 9 and 15 which are in the same infinite cycle: (..., 23, 9, 4, 2, 3, 7, 5, 15, 28, 120, 82, 46, ...).

Crossrefs

Inverse: A246378.
Other related or similar permutations: A135141, A054429, A246201, A245703, A246376, A246379, A243071, A246681, A236854.
Differs from A237427 for the first time at n=19, where a(19) = 29, while A237427(19) = 62.

Formula

a(1) = 1, and for n > 1, if A010051(n) = 1 [i.e. when n is a prime], a(n) = 1+(2*a(A000720(n))), otherwise a(n) = 2*a(A065855(n)).
As a composition of related permutations:
a(n) = A054429(A135141(n)).
a(n) = A135141(A236854(n)).
a(n) = A246376(A246379(n)).
a(n) = A246201(A245703(n)).
a(n) = A243071(A246681(n)). [For n >= 1].
Other identities.
For all n > 1 the following holds:
A000035(a(n)) = A010051(n). [Maps primes to odd numbers > 1, and composites to even numbers, in some order. Permutations A246379 & A246681 have the same property].

A246375 Permutation of natural numbers: a(1) = 1, a(2n) = 2*a(n), a(2n+1) = A003961(1+a(n)). [Where A003961(n) shifts the prime factorization of n one step towards larger primes].

Original entry on oeis.org

1, 2, 3, 4, 5, 6, 9, 8, 7, 10, 15, 12, 11, 18, 21, 16, 25, 14, 27, 20, 13, 30, 81, 24, 17, 22, 45, 36, 23, 42, 39, 32, 19, 50, 51, 28, 35, 54, 99, 40, 55, 26, 33, 60, 37, 162, 129, 48, 49, 34, 75, 44, 29, 90, 87, 72, 41, 46, 135, 84, 47, 78, 189, 64, 65, 38, 63, 100, 95, 102, 153, 56, 31, 70
Offset: 1

Views

Author

Antti Karttunen, Aug 27 2014

Keywords

Comments

This can be viewed as yet another "entanglement permutation" where the two complementary pairs to be interwoven together are even and odd numbers (A005843/A005408) which are entangled with the complementary pair even numbers (taken straight) and odd numbers in the order they appear in A003961: (A005843/A003961). Sequence A163511 has almost the same definition, but its domain starts from 0, which results a different permutation.

Crossrefs

Inverse: A246376.
Similar or related permutations: A005940, A005941, A163511, A245606, A246378, A246379.

Programs

  • PARI
    default(primelimit, (2^31)+(2^30));
    A003961(n) = my(f = factor(n)); for (i=1, #f~, f[i, 1] = nextprime(f[i, 1]+1)); factorback(f); \\ Using code of Michel Marcus
    A246375(n) = if(1==n, 1, if(!(n%2), 2*A246375(n/2), A003961(1+A246375((n-1)/2))));
    for(n=1, 16384, write("b246375.txt", n, " ", A246375(n)));
    (Scheme, with memoizing definec-macro)
    (definec (A246375 n) (cond ((<= n 1) n) ((even? n) (* 2 (A246375 (/ n 2)))) (else (A003961 (+ 1 (A246375 (/ (- n 1) 2)))))))

Formula

a(1) = 1, a(2n) = 2*a(n), a(2n+1) = A003961(1+a(n)). [Where A003961(n) shifts the prime factorization of n one step towards larger primes].
As a composition of related permutations:
a(n) = A246379(A246378(n)).
Other identities. For all n >= 1 the following holds:
A000035(a(n)) = A000035(n). [Like A005940 & A005941, this also preserves the parity].

A246380 Permutation of natural numbers: a(1) = 1, a(2n) = nthcomposite(a(n)), a(2n-1) = nthprime(a(A064989(2n-1)-1)), where nthprime = A000040, nthcomposite = A002808, and A064989(n) shifts the prime factorization of n one step towards smaller primes.

Original entry on oeis.org

1, 4, 2, 9, 7, 6, 23, 16, 3, 14, 13, 12, 43, 35, 17, 26, 37, 8, 101, 24, 5, 22, 19, 21, 53, 62, 83, 51, 79, 27, 233, 39, 191, 54, 149, 15, 103, 134, 11, 36, 47, 10, 151, 34, 41, 30, 29, 33, 73, 75, 241, 86, 113, 114, 89, 72, 1153, 108, 443, 40, 593, 296, 547, 56, 167, 245, 173, 76, 563, 194, 1553, 25
Offset: 1

Views

Author

Antti Karttunen, Aug 29 2014

Keywords

Comments

Has an infinite number of infinite cycles. See comments in A246379.

Crossrefs

Inverse: A246379.
Similar or related permutations: A246376, A246378, A246363, A246364, A246366, A246368, A064216, A246682.

Programs

  • PARI
    default(primelimit,(2^31)+(2^30));
    A002808(n) = { my(k=-1); while( -n + n += -k + k=primepi(n), ); n }; \\ This function from M. F. Hasler
    A064989(n) = {my(f); f = factor(n); if((n>1 && f[1,1]==2), f[1,2] = 0); for (i=1, #f~, f[i,1] = precprime(f[i,1]-1)); factorback(f)};
    A246380(n) = if(1==n, 1, if(!(n%2), A002808(A246380(n/2)), prime(A246380(A064989(n)-1))));
    for(n=1, 3098, write("b246380.txt", n, " ", A246380(n)));
    (Scheme, with memoization-macro definec)
    (definec (A246380 n) (cond ((< n 2) n) ((even? n) (A002808 (A246380 (/ n 2)))) (else (A000040 (A246380 (- (A064989 n) 1))))))

Formula

a(1) = 1, a(2n) = nthcomposite(a(n)), a(2n-1) = nthprime(a(A064989(2n-1)-1)), where nthprime = A000040, nthcomposite = A002808, and A064989(n) shifts the prime factorization of n one step towards smaller primes.
As a composition of related permutations:
a(n) = A246378(A246376(n)).
Other identities. For all n > 1 the following holds:
A010051(a(n)) = A000035(n). [Maps odd numbers larger than one to primes, and even numbers to composites, in some order. Permutations A246378 & A246682 have the same property].

A246682 Permutation of natural numbers: a(1) = 0, a(2) = 1, and for n > 1, a(2n) = nthcomposite(a(n)), a(2n-1) = nthprime(a(A064989(2n-1))), where nthprime = A000040, nthcomposite = A002808, and A064989(n) shifts the prime factorization of n one step towards smaller primes.

Original entry on oeis.org

0, 1, 2, 4, 3, 6, 5, 9, 7, 8, 11, 12, 31, 10, 13, 16, 127, 14, 709, 15, 19, 20, 5381, 21, 17, 46, 23, 18, 52711, 22, 648391, 26, 29, 166, 41, 24, 9737333, 858, 71, 25, 174440041, 30, 3657500101, 32, 37, 6186
Offset: 1

Views

Author

Antti Karttunen, Sep 01 2014

Keywords

Comments

Note the indexing: the domain starts from 1, while the range includes also zero.
Has an infinite number of infinite cycles. See comments at A246681.

Crossrefs

Inverse: A246681.
Similar or related permutations: A246376, A246378, A243071, A246368, A064216, A246380.

Programs

Formula

a(1) = 0, a(2) = 1, and for n > 1, a(2n) = nthcomposite(a(n)), a(2n-1) = nthprime(a(A064989(2n-1))), where nthprime = A000040, nthcomposite = A002808, and A064989(n) shifts the prime factorization of n one step towards smaller primes.
As a composition of related permutations:
a(n) = A246378(A243071(n)).
Other identities.
For all n >= 1 the following holds:
a(A000040(n)) = A007097(n-1). [Maps primes to the iterates of primes].
A049076(a(A000040(n))) = n. [Follows from above].
For all n > 1 the following holds:
A010051(a(n)) = A000035(n). [Maps odd numbers larger than one to primes, and even numbers to composites, in some order. Permutations A246378 & A246380 have the same property].

A269866 Permutation of natural numbers: a(1) = 1, a(2n) = 2*a(n), a(2n+1) = 1 + 2*a(A268674(2n+1)-1).

Original entry on oeis.org

1, 2, 3, 4, 5, 6, 9, 8, 7, 10, 13, 12, 21, 18, 11, 16, 25, 14, 33, 20, 19, 26, 29, 24, 17, 42, 15, 36, 53, 22, 73, 32, 27, 50, 37, 28, 45, 66, 43, 40, 57, 38, 81, 52, 23, 58, 77, 48, 49, 34, 51, 84, 117, 30, 41, 72, 67, 106, 169, 44, 213, 146, 39, 64, 85, 54, 89, 100, 59, 74, 109, 56, 149, 90, 35, 132, 101, 86, 113, 80, 31
Offset: 1

Views

Author

Antti Karttunen, Mar 12 2016

Keywords

Crossrefs

Inverse: A269865.
Cf. A268674.
Related or similar permutations: A269867, A249813, A252756, A270196.
Differs from similarly constructed A246376 for the first time at n=21, where a(21) = 19, instead of 15.

Formula

a(1) = 1, a(2n) = 2*a(n), a(2n+1) = 1 + 2*a(A268674(2n+1)-1).

A269853 Permutation of natural numbers: a(1) = 1, a(2n) = 2*a(n), a(2n+1) = 1 + 2*a(A064216(n)).

Original entry on oeis.org

1, 2, 3, 4, 5, 6, 7, 8, 11, 10, 9, 12, 15, 14, 19, 16, 13, 22, 31, 20, 27, 18, 21, 24, 63, 30, 23, 28, 17, 38, 43, 32, 35, 26, 29, 44, 39, 62, 87, 40, 37, 54, 79, 36, 75, 42, 25, 48, 159, 126, 127, 60, 61, 46, 51, 56, 55, 34, 53, 76, 123, 86, 107, 64, 41, 70, 71, 52, 247, 58, 125, 88, 143, 78, 251, 124, 45, 174, 59, 80, 287, 74, 33
Offset: 1

Views

Author

Antti Karttunen, Mar 16 2016

Keywords

Crossrefs

Programs

  • Mathematica
    a[1] = 1; a[n_] := a[n] = If[EvenQ@ n, 2 a[n/2], 1 + 2 a[Times @@ Power[If[# == 1, 1, NextPrime[#, -1]] & /@ First@ #, Last@ #] &@ Transpose@ FactorInteger[(n - 1) - 1]]]; Table[a@ n, {n, 83}] (* Michael De Vlieger, Mar 23 2016 *)

Formula

a(1) = 1, after which for even n, a(n) = 2*a(n/2), for odd n, a(n) = 1 + 2*a(A064989(n-2)).
Showing 1-7 of 7 results.