Tag Info

Hot answers tagged

14

You can just step through $i$ and $j$ while trying to simultaneously satisfy: $$i^2+(i+1)^2=j^2+(j+1)^2+(j+2)^2$$ Just loop and if the inequality is too small on the left, increment $i$. If it's too small on the right, increment $j$. That looks like this: Clear[f, g, i, j]; f[i_] = i^2 + (i + 1)^2; g[j_] = j^2 + (j + 1)^2 + (j + 2)^2; max = 10^6; i = 1; j ...


11

Update: the lhs of $i^2+(i+1)^2=j^2+(j+1)^2+(j+2)^2$ is always odd so $j$ should be even. The fastest solution I found: max = 10^12; {(Sqrt[3 + 6 (# + 1)^2] - 1)/2, #, #^2 + (# + 1)^2 + (# + 2)^2} & @@@ (2 Position[#, 0]) &@UnitStep[Abs[# - Round[#]] - 1.*^-10] &[ Sqrt[0.75 + 1.5 #^2] - 0.5] &@ Range[3., Sqrt[max/3.], 2] // ...


9

Clear[fa, ga]; fa = Total[{#, # + 1}^2] &; ga = Total[{#, # + 1, # + 2}^2] &; Update: A closed form function soln = Assuming[{C[1] ∈ Integers && C[1] >= 0 && x > 0 && y > 0}, Simplify@ Reduce[Total[{x, x + 1}^2] == Total[{y, y + 1, y + 2}^2], {x, y}, Integers]] /. C[1] -> n; ...


4

This is not particularly fast but works: f = (-1 + Sqrt[3 + 6 #^2])/2 &; q = IntegerQ /@ (f /@ Range[1000000]); answer = Pick[Range[1000000], q] yields the triples : {1, 11, 109, 1079, 10681, 105731} fanswer = f /@ answer {1, 13, 133, 1321, 13081, 129493} Dropping first case which is 0^2+1^2+2^2=1^2+2^2: trip = Rest[{(# - 1), #, # + 1} & /@ ...


3

my stab at it, unfortunately only a marginal improvement in time: ii=13; Clear[a, b]; b = FoldList[Times, 1, Table[ Exp[MangoldtLambda[n]], {n, 2, ii}]]; a = Prepend[Table[ Limit[ Zeta[s] Total[Exp[Divisors[n]]^(s - 1) MoebiusMu[Divisors[n]]], s -> 1], {n, 2, ii}], 1] ; Monitor[aa = Prepend[Table[ ...


2

I realized now that I included unnecessary many terms of the Dirichlet inverse of the Euler totient. Therefore a better program is: ii = 13 aa = Range[ii]*0; Monitor[Do[ Clear[A, a, b, n, k]; b = Table[Product[Exp[MangoldtLambda[n]], {n, 1, k}], {k, 1, nn}]; a = Table[ If[n == 1, 1, Limit[Zeta[s] Total[ Exp[Divisors[n]]^(s - ...


1

Factoring algorithms work by finding a prime factor, then dividing by it, then continuing on the result, and so the prime factors are found in essentially random order, unless your algorithm is trial division (which I hope to God mathematica does not use). So, the answer to your question is: filtering is your only solution. EDIT On the other hand, the OP's ...



Only top voted, non community-wiki answers of a minimum length are eligible