Last active
November 1, 2020 22:21
Comparision of a136437 and a338530
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Regarding | |
# https://oeis.org/draft/A338530 | |
# https://oeis.org/A136437 | |
# | |
# Hugo Pfoertner: Can you please check the relation to A136437? It seems that (a(n)+2)/2 = (A136437-1)/2 for the even terms after a(31). | |
# Hugo Pfoertner: I checked against A136437 and found a(n)=A136437(n)-3 for 31<=n<=128. | |
# | |
# Here is output of the two sequences A136437 and A338530. They are indeed the same for this range. | |
# | |
require 'prime' | |
# https://oeis.org/A136437 | |
def a136437(count) | |
values = [] | |
Prime.first(count).each do |prime| | |
k, v = 1, 1 | |
(k += 1; v *= k) while (k + 1) * v <= prime | |
values << prime - v | |
end | |
values | |
end | |
# https://oeis.org/draft/A338530 | |
def a338530(count) | |
primes = Prime.first(count) | |
values = [1] | |
(count-1).times { |n| values << (primes[n+1] + values[-1]) % primes[n] } | |
values | |
end | |
values0 = a136437(128).drop(30) | |
puts "A136437 #{values0}" | |
values1 = a338530(128).drop(30).map { |v| v + 3 } | |
puts "\nA338530 #{values1}" | |
raise "the values are different" if values0 != values1 | |
puts "\nThe values are identical." | |
=begin | |
PROGRAM OUTPUT IS HERE: | |
A136437 [7, 11, 17, 19, 29, 31, 37, 43, 47, 53, 59, 61, 71, 73, 77, 79, 91, 103, 107, 109, 113, 119, 121, 131, 137, 143, 149, 151, 157, 161, 163, 173, 187, 191, 193, 197, 211, 217, 227, 229, 233, 239, 247, 253, 259, 263, 269, 277, 281, 289, 299, 301, 311, 313, 319, 323, 329, 337, 341, 343, 347, 359, 367, 371, 379, 383, 389, 401, 403, 421, 427, 437, 443, 449, 451, 457, 467, 473, 479, 481, 487, 493, 497, 499, 511, 521, 523, 527, 533, 539, 541, 553, 557, 563, 571, 581, 589, 599] | |
A338530 [7, 11, 17, 19, 29, 31, 37, 43, 47, 53, 59, 61, 71, 73, 77, 79, 91, 103, 107, 109, 113, 119, 121, 131, 137, 143, 149, 151, 157, 161, 163, 173, 187, 191, 193, 197, 211, 217, 227, 229, 233, 239, 247, 253, 259, 263, 269, 277, 281, 289, 299, 301, 311, 313, 319, 323, 329, 337, 341, 343, 347, 359, 367, 371, 379, 383, 389, 401, 403, 421, 427, 437, 443, 449, 451, 457, 467, 473, 479, 481, 487, 493, 497, 499, 511, 521, 523, 527, 533, 539, 541, 553, 557, 563, 571, 581, 589, 599] | |
The values are identical. | |
=end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment