June 2018 Update
This commit is contained in:
parent
ba8067c3b7
commit
22f33d4004
5278 changed files with 84726 additions and 14379 deletions
|
|
@ -30,7 +30,7 @@
|
|||
N = IT !A copy I can damage.
|
||||
NF = 0 !No factors found.
|
||||
P = 0 !Because no primes have been tried.
|
||||
PP:DO WHILE (IT.GT.1) !Step through the possibilities.
|
||||
PP:DO WHILE (N.GT.1) !Step through the possibilities.
|
||||
P = P + 1 !Another prime impends.
|
||||
F = PRIME(P) !Grab a possible factor.
|
||||
POW = 0 !It has no power yet.
|
||||
|
|
@ -48,11 +48,10 @@
|
|||
STOP "Not enough storage!" !Quite.
|
||||
END IF !But normally,
|
||||
NF = NF + 1 !Admit another factor.
|
||||
FACTOR.PNUM(NF) = P !Identify the prime.
|
||||
FACTOR.PNUM(NF) = P !Identify the prime. NOT the prime itself.
|
||||
FACTOR.PPOW(NF) = POW !Place its power.
|
||||
END IF !So much for that factor.
|
||||
IF (N.LE.1) EXIT PP !Perhaps nothing remains?
|
||||
END DO PP !Try another prime.
|
||||
END DO PP !Try another prime, if N > 1 still.
|
||||
FACTOR.PNUM(0) = NF !Place the count.
|
||||
END FUNCTION FACTOR !Thus, a list of primes and their powers.
|
||||
|
||||
|
|
|
|||
32
Task/Fractran/Julia/fractran.julia
Normal file
32
Task/Fractran/Julia/fractran.julia
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
function fractran(n::Integer, ratios::Vector{<:Rational}, steplim::Integer)
|
||||
rst = zeros(BigInt, steplim)
|
||||
for i in 1:steplim
|
||||
rst[i] = n
|
||||
if (pos = findfirst(x -> isinteger(n * x), ratios)) > 0
|
||||
n *= ratios[pos]
|
||||
else
|
||||
break
|
||||
end
|
||||
end
|
||||
return rst
|
||||
end
|
||||
|
||||
using IterTools
|
||||
macro ratio_str(s)
|
||||
a = split(s, r"[\s,/]+")
|
||||
return collect(parse(BigInt, n) // parse(BigInt, d) for (n, d) in partition(a, 2))
|
||||
end
|
||||
|
||||
fracs = ratio"""17 / 91, 78 / 85, 19 / 51, 23 / 38, 29 / 33, 77 / 29, 95 / 23,
|
||||
77 / 19, 1 / 17, 11 / 13, 13 / 11, 15 / 14, 15 / 2, 55 / 1"""
|
||||
println("The first 20 in the series are ", fractran(2, fracs, 20))
|
||||
|
||||
prmfound = 0
|
||||
n = big(2)
|
||||
while prmfound < 20
|
||||
if isinteger(log2(n))
|
||||
prmfound += 1
|
||||
println("Prime $prmfound found: $n is 2 ^ $(Int(log2(n)))")
|
||||
end
|
||||
n = fractran(n, fracs, 2)[2]
|
||||
end
|
||||
|
|
@ -1,3 +1,6 @@
|
|||
sub fractran(@program) {
|
||||
2, { first Int, map (* * $_).narrow, @program } ... 0
|
||||
}
|
||||
for fractran <17/91 78/85 19/51 23/38 29/33 77/29 95/23 77/19 1/17 11/13 13/11
|
||||
15/14 15/2 55/1> {
|
||||
say $++, "\t", .msb, "\t", $_ if 1 +< .msb == $_;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
str = %w[17/91 78/85 19/51 23/38 29/33 77/29 95/23 77/19 1/17 11/13 13/11 15/14 15/2 55/1]
|
||||
FractalProgram = str.map(&:to_r) #=> array of rationals
|
||||
ar = %w[17/91 78/85 19/51 23/38 29/33 77/29 95/23 77/19 1/17 11/13 13/11 15/14 15/2 55/1]
|
||||
FractalProgram = ar.map(&:to_r) #=> array of rationals
|
||||
|
||||
Runner = Enumerator.new do |y|
|
||||
num = 2
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue