Jump to content

Sequence: nth number with exactly n divisors: Difference between revisions

m
→‎simple: use get_prime()
m (Phix/mpfr)
m (→‎simple: use get_prime())
Line 836:
whereas a limit of 25 would need to invoke factors() 52 million times which would no doubt take a fair while.
<lang Phix>constant LIMIT = 24
constant LIMIT = 24
include mpfr.e
mpz z = mpz_init()
 
sequence fn = 1&repeat(0,LIMIT-1),
primes = {2,3}
integer k = 1
printf(1,"The first %d terms in the sequence are:\n",LIMIT)
for i=1 to LIMIT do
sequenceif f = factorsis_prime(i,1) then
mpz_ui_pow_ui(z,primes[get_prime(i]),i-1)
if length(f)=2 then -- i is prime (f is {1,i})
while length(primes)<i do
integer p = primes[$]+2
while prime_factors(p)!={} do p += 2 end while
primes = append(primes,p)
end while
mpz_ui_pow_ui(z,primes[i],i-1)
printf(1,"%2d : %s\n",{i,mpz_get_str(z)})
else
Line 892 ⟶ 886:
24 : 1170
</pre>
 
===cheating slightly===
No real patterns that I could see here, but you can still identify and single out the troublemakers (of which there are about 30).
7,820

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.