Talk:Square form factorization: Difference between revisions
Content added Content deleted
No edit summary |
m (test ditty) |
||
Line 172: | Line 172: | ||
Can't say I really followed that, nevermind, a translation of the 2nd C entry fixed my problems. --[[User:Petelomax|Pete Lomax]] ([[User talk:Petelomax|talk]]) 19:23, 20 March 2021 (UTC) |
Can't say I really followed that, nevermind, a translation of the 2nd C entry fixed my problems. --[[User:Petelomax|Pete Lomax]] ([[User talk:Petelomax|talk]]) 19:23, 20 March 2021 (UTC) |
||
Just to prove things we working as they should, I wrote a little ditty |
|||
<lang Phix>integer prev = 3 |
|||
sequence res = {}, r |
|||
for n=3 to 100_000 do |
|||
integer p = get_prime(n) |
|||
for N=prev+2 to p-2 by 2 do |
|||
atom f = squfof(N) |
|||
if f=1 then |
|||
sequence pf = prime_factors(N) |
|||
if length(pf)=1 and N=power(pf[1],3) then |
|||
r = sprintf("%d (%d cubed)",{N,pf[1]}) |
|||
else |
|||
r = sprintf("%d (factors: %v)",{N,pf}) |
|||
end if |
|||
res = append(res, r) |
|||
end if |
|||
end for |
|||
prev = p |
|||
end for |
|||
puts(1,join_by(res,3,10))</lang> |
|||
and got this, the only things that fail below 1,000,000 are indeed cubes of primes, just as advertised: |
|||
<pre> |
|||
24389 (29 cubed) 103823 (47 cubed) 226981 (61 cubed) 389017 (73 cubed) 704969 (89 cubed) 1092727 (103 cubed) |
|||
68921 (41 cubed) 148877 (53 cubed) 300763 (67 cubed) 493039 (79 cubed) 912673 (97 cubed) 1225043 (107 cubed) |
|||
79507 (43 cubed) 205379 (59 cubed) 357911 (71 cubed) 571787 (83 cubed) 1030301 (101 cubed) 1295029 (109 cubed) |
|||
</pre> |