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
import Foundation | |
import PlaygroundSupport | |
/// A thread-safe array. | |
public class SynchronizedArray<Element> { | |
fileprivate let queue = DispatchQueue(label: "io.zamzam.ZamzamKit.SynchronizedArray", attributes: .concurrent) | |
fileprivate var array = [Element]() | |
} | |
// MARK: - Properties |
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
// Copyright © 2019 Simon Strandgaard. All rights reserved. | |
import SwiftyBeaver | |
public let log = SwiftyBeaver.self | |
extension BaseDestination.LevelColor { | |
mutating func applyDefaultStyle() { | |
debug = "🏐 " | |
info = "🏐 " | |
verbose = "🏐 " |
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
# Mesolabe Compass and Square Roots - Numberphile | |
# https://www.youtube.com/watch?v=9VVPBS_flOI | |
v=4; Math.sin(Math.acos(2.0 / (v + 1) - 1.0)) * (v + 1) / 2.0 | |
# 2.0000000000000004 | |
v=9; Math.sin(Math.acos(2.0 / (v + 1) - 1.0)) * (v + 1) / 2.0 | |
# 3.0 | |
v=16; Math.sin(Math.acos(2.0 / (v + 1) - 1.0)) * (v + 1) / 2.0 |
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
require 'prime' | |
PRIMES = Prime.first(1000) | |
# Kevin Ryde pointed out that A337724 corresponds to this formula, with crazy rounding | |
# prime(n) - prime(n-2)/2 + prime(n-4)/2^2 - prime(n-6)/2^3 + ... | |
values = [0, 1] | |
30.times do |i| | |
sum = 0 | |
power = 0 | |
sign = 1 |
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
require 'prime' | |
PRIMES = Prime.first(1000) | |
# Kevin Ryde pointed out that A337724 corresponds to this formula, with crazy rounding | |
# prime(n) - prime(n-2)/2 + prime(n-4)/2^2 - prime(n-6)/2^3 + ... | |
# What about A337723, does it have a similar formula, with crazy rounding? | |
# Yes, I think I have found a formula that can do it. | |
accumulator_a = 0.5 | |
accumulator_b = 1 |
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' |
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
use std::io::Write; | |
std::env::set_var("RUST_LOG", "debug"); | |
env_logger::builder() | |
.format(|buf, record| { | |
writeln!(buf, "{} - {}:{} - {}", record.level(), record.file().unwrap_or("N/A"), record.line().unwrap_or(0), record.args()) | |
}) | |
.init(); |
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
# 2.920050977316 - A Prime-Representing Constant | |
# by Dylan Fridman, Juli Garbulsky, Bruno Glecer, James Grime, Massi Tron Florentin | |
# | |
# Numberphile | |
# https://www.youtube.com/watch?v=_gCKX6VMvmU | |
# | |
# Article | |
# https://arxiv.org/abs/2010.15882 | |
# | |
# OEIS sequence |
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
require 'prime' | |
def plot(values, modvalue) | |
puts | |
puts "plot(values, #{modvalue})" | |
s = values.map {|v| (v % modvalue).to_s(modvalue) }.join('') | |
modvalue.times do |i| | |
value = i.to_s(modvalue) | |
re = Regexp.new("[^" + value + "]") | |
puts '# ' + s.gsub(re, ' ') |
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
def plot_modulus(values, count) | |
puts | |
s = values.map {|v| v.to_s(count) }.join('') | |
count.times do |i| | |
value = i.to_s(count) | |
re = Regexp.new("[^" + value + "]") | |
puts '# ' + s.gsub(re, ' ') | |
end | |
end |