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.

User: Andy Martin

Andy Martin's wiki page.

Andy Martin has authored 6 sequences.

A275939 Consider the prime race mod q (where q >= 2) between q*k+1 and q*k-1. Terms are numbers k where q*k+1 first takes lead over q*k-1.

Original entry on oeis.org

3, 608981813029, 26861, 11, 608981813017, 71, 192252423729713, 37, 11, 23
Offset: 2

Author

Andy Martin, Aug 12 2016

Keywords

Comments

Values are available for all 2 <= q <= 999 except for 12 and 24. If q is odd and > 3 then 2*q will have the same value in the sequence as q.
Additional terms starting with q = 12 are:
unknown, 53, 71, 331, 17, 239, 37, 213827, 1381, 673, 23, 47, unknown, 101, 53, 379, 29, 59, 331
The longest q*k+1 versus q*k-1 races up to q = 999 are for q = 3,6,8,12,24 and 168. When q = 168 the race ends at prime 273084304417.
The mod 12 and 24 races were checked by computer to 1.1 * 10^14 without q*k+1 ever leading.
Kevin Ford (private communication) provides the following information on these races: "My paper with Richard Hudson contains a lot of information about the location of sign changes for pi(x,q,a)-pi(x,q,b). Corollary 4 has rigorous upper bounds, but these will likely not be useful to you. The information in Tables 2 and 3 will be more helpful, as these provide the most likely places to look for the first sign change. In the case of the mod 12 race, it is probably around exp(187.536), or about 2.79 x 10^{81}. For the mod 24 race, it's about exp(43.453)=7.437... x 10^{18}".

Examples

			For the fourth term q is 5. For primes 2,3,5 and 7 the mod 5 values are 2,3,0 and 2 respectively, so there is no change in the race. For the next prime 11, mod 5 gives 1, q*k+1 now leads 1 to 0, and the race is over.
		

References

  • Ford, Kevin; Konyagin, Sergei; Chebyshev's conjecture and the prime number race. IV International Conference "Modern Problems of Number Theory and its Applications": Current Problems, Part II (Russian) (Tula, 2001), 67-91.
  • Paulo Ribenboim, The Little Book of Big Primes, Springer 1991

Crossrefs

Programs

  • C
    /*
    C language program used to investigate prime number races.
    Computes the first lead of qn+1 over qn-1 for q from 2 to 999.
    By Andy Martin oldadit@gmail.com 8/12/2016.
    Requires Kim Walisch's primesieve library from http://primesieve.org
    Iteration based on the primesieve_iterator.c example.
    */
    #include 
    #include 
    #include 
    #define UPDATE_COUNT 10000000000ull
    void race(uint64_t q)
    {
      uint64_t prime  = 0;
      uint64_t m1     = 0;
      uint64_t m_1    = 0;
      uint64_t rem    = 0;
      uint64_t update = UPDATE_COUNT;
      primesieve_iterator pi;
      primesieve_init(&pi);
      while (prime = primesieve_next_prime(&pi)) {
        if ((rem = prime % q) == 1){
          m1 += 1;
        } else if (rem == q-1) {
          m_1 += 1;
        }
        if (m1 > m_1){
          printf("Race mod %3llu ends at %12llu with %11llu pi(x;%llu,1) and %11llu pi(x;%llu,%llu)\n",
                 q, prime, m1, q, m_1, q, q-1);
          break;
        }
        /* Enable for update on long races where q = 3,6,8,12,24,168 */
        if (prime > update) {
          printf("  Race mod %llu ongoing at prime %llu with m1 %llu and m_1 %llu diff: %llu\n",
                 q, prime, m1, m_1, m_1 - m1);
          update += UPDATE_COUNT;
        }
      }
      primesieve_free_iterator(&pi);
    }
    int main()
    {
      uint64_t i;
      for(i=2; i<1000; i++){ race(i); }
      return(0);
    }

Extensions

a(8)-a(11) from Andy Martin, Aug 15 2016

A272043 a(n) is the shyest prime in base n.

Original entry on oeis.org

2, 3, 31, 13, 523, 31, 3833, 491, 5483, 523, 18149, 661, 44657, 3833, 18869, 7333, 165479, 5483, 153953, 20411, 129127, 18149, 538651, 7079, 932257, 44657, 417037, 52639, 2223773, 18869, 3124217, 175229, 1993763, 165479, 2794811, 50461, 8678963, 153953
Offset: 1

Author

Andy Martin, Apr 18 2016

Keywords

Comments

Terminology: consider pairs of final digits of consecutive primes (a,b). Then of all pairs (3,1) is found last in the prime sequence, corresponding to (523, 541). This is termed the shyest pair, with 523 the shyest prime.
Consider final digit pairs (a,b) of consecutive primes.
There are three unique pairs: (2, 3) (3, 5) (5, 7)
For the remaining 16 pairs, record the first observed primes corresponding to the pair:
Initial prime -- Second prime (mod 10) ---
(mod 10) 1 3 7 9
1 181,191 11, 13 31, 37 401,409
3 523,541 283,293 13, 17 23, 29
7 7, 11 47, 53 337,347 17, 19
9 29, 31 19, 23 89, 97 139,149
523,541 is the largest pair, thus the last to occur in the sequence of primes. The first member of this pair is the shyest prime, base 10. (Note that if we consider two digit pairs (ab, cd) then 40191937, 40192037 is the shyest pair for base 10.)
For base 3 the table is:
Initial prime Second prime (mod 3)
(mod 3) 0 1 2
0 - - 3,5
1 - 31,37 7,11
2 2,3 5,7 23,29
and 31 is the shyest prime base 3.

Crossrefs

Programs

  • Mathematica
    a[n_] := Block[{g,p,m,q,k, e= First /@ Select[ Tally[ Mod[ Prime@ Range[n* 100], n]], #[[2]] > 50 &], A}, A = Association@ Table[{i,j} -> 0, {i,e}, {j,e}]; g = Length[e]^2; m=p=2; While[g > 0, q = NextPrime@p; k = Mod[{p, q}, n]; If[ Lookup[A, Key@k, 1] == 0, A[k] = 1; g--]; m=p; p=q]; m]; Array[a, 25] (* Giovanni Resta, Apr 19 2016 *)
  • Ruby
    require 'Prime'
    # Ruby Code
    # Generates Hash with first occurrences of all possible pairs (a,b)
    # of final digits for consecutive primes in specified base.
    def gen_hash(h, base)
      last_prime = 2
      iteration = last_found = 0
      Prime.each() do |prime|
        # This check could be improved & may be invalid for bases above 35.
        return if (iteration+=1) > 10000 && iteration > 2 * last_found
        next if prime == 2
        l =  last_prime.to_s(base)[-1]
        p =  prime.to_s(base)[-1]
        if h[[l,p]].nil?
          h[[l,p]] = [last_prime,prime]
          last_found = iteration
        end
        last_prime = prime
      end
    end
    puts "First Prime  Second Prime  Base  Difference  Different  Final Digits In"
    puts "                                                 Pairs    Base Notation"
    puts "          2             3     1           1          1              1 1"
    # For bases above 35 additional programming needed.
    2.upto(35){|base|
      gen_hash(h = Hash.new, base)
      p0 = h.values.sort.last[0]
      p1 = h.values.sort.last[1]
      printf("%11d  %12d  %4d  %10d %10d              %s %s\n",
      p0, p1, base, p1 - p0, h.length, p0.to_s(base)[-1], p1.to_s(base)[-1])
    }

Extensions

a(22)-a(38) from Giovanni Resta, Apr 19 2016

A178983 The smallest cube containing n as a substring.

Original entry on oeis.org

0, 1, 27, 343, 64, 125, 64, 27, 8, 729, 1000, 91125, 125, 1331, 140608, 15625, 216, 1728, 85184, 2197, 205379, 216, 226981, 103823, 13824, 125, 9261, 27, 1728, 729, 39304, 1331, 5832, 1331, 343, 35937, 97336, 3375, 13824, 39304, 4096, 531441, 42875, 343
Offset: 0

Author

Andy Martin, Jan 02 2011

Keywords

Examples

			a(3) = 7^3 = 343, because it contains 3 as a substring and no smaller cube contains 3.
		

Crossrefs

Programs

  • Mathematica
    subs[n_] := Module[{d = IntegerDigits[n], len}, len = Length[d]; Union[Flatten[Table[FromDigits[Take[d, {i, k}]], {k, len}, {i, k}]]]]; Table[k = 0; While[! MemberQ[subs[k^3], n], k++]; k^3, {n, 0, 100}] (* T. D. Noe, Nov 06 2013 *)
    With[{cbs=Range[0,100]^3},Table[SelectFirst[cbs,SequenceCount[IntegerDigits[#],IntegerDigits[n]]>0&],{n,0,50}]] (* Harvey P. Dale, Nov 17 2024 *)
  • Ruby
    # For a given nonnegative integer n,
    # find the smallest nonnegative cube that contains it as a substring.
    NUM_TERMS = 30
    (0...NUM_TERMS).each{ |i|
      (0..(1.0/0.0)).each{ |j|
        (print "#{j*j*j}" + ", "; break) if "#{j*j*j}".include?("#{i}")
      }
    }

Extensions

Edited by Alois P. Heinz, Jan 02 2011

A161170 Least integer k such that the n-almost prime count is equal to the prime count.

Original entry on oeis.org

10, 125, 1809, 37820, 2722768, 1037849736, 4204496515890, 476649763963226416
Offset: 2

Author

Andy Martin, Jun 04 2009

Keywords

Comments

Related to sequence A125149, but we compare the prime count to the semiprime count, then the product-of-three-primes count, and so on.
We start with a the number two, and a prime count of 1.
Then the prime count and semiprime count are first identical when k = 10, the prime count is 4 ({2, 3, 5, 7}) and the semiprime count is also 4 ({4, 6, 9, 10}).
Next, when k = 125 the prime count of 30 and product-of-three-primes count of 30 are first identical.
Based on the write up for A125149 and examination of the factor counts as k increases, we believe this sequence is infinite, but have not proved this.

Examples

			a(2) = 10 since there are now 4 primes ({2, 3, 5, 7}) and 4 semiprimes ({4, 6, 9, 10}) <= 10.
a(3) = 125 with 30 primes and 30 products of 3 primes.
a(4) = 1809 with 279 primes and 279 products of 4 primes.
a(5) = 37820 with 4000 primes and 4000 products of 5 primes.
a(6) = 2722768 with 198183 primes and 198183 products of 6 primes.
a(7) = 1037849736 with 52672391 primes and 52672391 products of 7 primes.
a(8) = 4204496515890 with 150007470826 primes and 150007470826 products of 8 primes.
a(9) = 476649763963226416 with 12012658440940682 primes and 12012658440940682 products of 9 primes.
		

Crossrefs

Cf. A125149.

Programs

  • Perl
    use ntheory ":all"; my($k,@S)=(0,map{0}1..20); forfactored { $S[@]++; while ($S[1] == $S[$k]) { print "$k $\n" if $k>1; $k++; } } 3e6; # Dana Jacobsen, Jan 18 2019
  • Ruby
    # A slow program to generate sequence
    # Faster C code is available by request
    # Tallies number of primes, semiprimes, trieneprimes ...
    tally = Hash.new { |h,k| h[k] = 0}
    # Returns number of factors of num
    def factors(num)
    (2..(Math.sqrt(num).to_i)).each{ |i|
    return factors(num/i) + 1 if num % i == 0
    }
    1
    end
    # Testing number of primes against composites with num_factors
    num_factors = 2
    2.upto( 1.0/0.0 ) { |i|
    tally[factors(i)] +=1
    if tally[1] == tally[num_factors]
    puts "k: #{i} Primes: #{tally[1]} Composites with #{num_factors} factors: #{tally[num_factors]}"
    num_factors += 1
    end
    }
    

Extensions

Edited example and a(8) from Donovan Johnson, Mar 10 2010
a(9) from Henri Lifchitz, Mar 17 2025

A173515 Consider positive integer solutions to x^3+ y^3 = z^3 - n or 'Fermat near misses' of 1, 2, 3 ... Arrange known solutions by increasing values of n. Sequence gives value of lowest z for a given n.

Original entry on oeis.org

9, 7, 2, 812918, 18, 217, 4, 3, 9730705, 332, 14, 135, 3, 19, 156, 16, 15584139827, 3, 139643, 6, 1541, 4, 2220422932, 5, 14, 4, 445, 12205, 9, 8, 16234, 815, 31, 4
Offset: 1

Author

Andy Martin, Feb 20 2010

Keywords

Comments

The submitted values are for z when 0 < n < 51. There is no solution for any n congruent to 4 or 5 mod 9. This eliminates 4,5,13,14,22,23,31,32,40,41,49 and 50 in the 0-to-50 range.
Per the Elsenhans and Jahnel link there are no solutions found for 3, 33, 39 and 42 in the 0-to-50 range, with a search bound of 10^14.
If sequences could contain 'nil' for no solution, and '?' for cases where a solution is not known, but might exist, then a more concise definition is possible: Least positive integer such that a(n)^3 - n is the sum of two positive cubes. The sequence would then start: 9, 7, ?, nil, nil, 2.

Examples

			6^3 + 8^3 = 9^3 - 1: There are no solutions when n = 1 for z < 9, thus the first term is 9.
5^3 + 6^3 = 7^3 - 2: There are no solutions for z < 7, thus the second term is 7.
It is unknown if there is a solution when n = 3.
It is known there are no solutions when n = 4 and 5.
1^3 + 1^3 = 2^3 - 6, thus the third term is 2.
		

Crossrefs

Programs

  • Ruby
    # x^3 + y^3 = z^3 - n
    # Solve for all z less than z_limit, and
    # n less than n_limit.
    # When n = 7, z = 812918 and faster code and language are needed.
    # However, by optimizing this code slightly and running for 2 days
    # the author was able to search all z < 164000 and n < 100
    #
    n_limit = 7 # Configure as desired
    z_limit = 20 # Configure as desired
    h = {}
    (2..z_limit).each{ |z|
      (1..(z-1)).each{ |y|
      (1..(y)).each{ |x|
      n = z*z*z - x*x*x - y*y*y
      if n > 0 && n < n_limit && h[n].nil?
      puts "Found z = #{z} when #{x}^^3 + #{y}^^3 = #{z}^^3 - #{n}"
      h[n] = z
      end
    } } } print "\nPartial sequence generated when n < #{n_limit} and z is searched to #{z_limit} is:\n"
    h.sort.each{|k,v| print "#{v}, " }
    print "\b\b \n"

Formula

Author conjectures that no explicit formula or recurrence exists.

A137442 n^2 followed by smallest integer not yet listed.

Original entry on oeis.org

1, 2, 4, 3, 9, 5, 16, 6, 25, 7, 36, 8, 49, 10, 64, 11, 81, 12, 100, 13, 121, 14, 144, 15, 169, 17, 196, 18, 225, 19, 256, 20, 289, 21, 324, 22, 361, 23, 400, 24, 441, 26, 484, 27, 529, 28, 576, 29, 625, 30, 676, 31, 729, 32, 784, 33, 841, 34, 900, 35, 961, 37, 1024, 38
Offset: 1

Author

Andy Martin, Apr 18 2008

Keywords

Comments

Sequence is a permutation of the positive integers.

Crossrefs

Cf. A000463.

Programs

  • Mathematica
    f[s_List] := Block[{k = 1}, While[ MemberQ[s, k], k++ ]; Flatten@ Append[s, {((2 + Length@s)/2)^2, k}]]; Nest[f, {1, 2}, 33] (* Robert G. Wilson v, May 31 2009 *)
    Module[{nn=40,sq,int,len},sq=Range[nn]^2;int=Complement[Range[nn],sq];len=Min[Length[int],nn];Riffle[Take[sq,len],Take[int,len]]](* Harvey P. Dale, Nov 05 2013 *)
  • PARI
    lista(nn) = {for (n=1, nn, print1(n^2, ", ", n+round(sqrt(n)), ", "););} \\ Michel Marcus, Nov 02 2014
    
  • PARI
    a(n) = if (n % 2, ((n+1)/2)^2, (n/2)+round(sqrt(n/2))); \\ Michel Marcus, Nov 02 2014
  • Ruby
    # correct to any term:
    sk_ct = 2
    skip = 4
    at = 1
    (1..(1.0/0)).each{ |i|
    if (at+=1) == skip
    at+=1
    sk_ct +=1
    skip = sk_ct * sk_ct
    end
    print i*i, " ", at, " "
    }
    
  • Ruby
    # Simpler Ruby code, correct until i is so large that floating point rounding causes errors. I estimate this will be before i reaches 10000000000000000
    (1..(1.0/0)).each{ |i|
    print i*i, " ", i + (Math.sqrt(i) + 0.5).to_i, " "
    }
    

Formula

Formula, generating two terms for every m: m^2, m + round(sqrt(m)).
IFTE(n mod 2 ==1, ((n+1)/2)^2, (n/2)+round(sqrt(n/2),0)). - Gerald Hillier, Nov 15 2010

Extensions

More terms from Robert G. Wilson v, May 31 2009