Hello,

On Mar 22, 7:16 am, christophe van der putten
<christophe.v...@gmail.com> wrote:
> Hi,
> I am a newbie with sage, a want to save in a text file all prime and
> prime power that are lower than a big number Max=(10^18).
>
> i use two loop:  as below and i have the error message "maximum
> recursion depht exceded".
> the program that i write is:
>
> "
> sage:
>  k=1
>  p=2
>  m=2
>   while p^k<=Max:
>      while p^k <=Max:
>           m=p^k
>           print m
>           save(k,c:\result.txt)
>      k=k + 1
>   k=1
>   p=next_prime(p)

It's hard to tell what's going on since the above is not valid Python
syntax ( save(k,c:\result.txt), etc. )  I think the best way to do
what you want is something like what's at http://www.sagenb.org/home/pub/393
.  Note that it's not computationally feasible to generate all of
these up to 10^18.  For example, just going up to 10^8 already takes
40 seconds.

sage: cap = 10^8
sage: t = cputime()
sage: n = 2
sage: while n < cap:
....:     n = next_prime(n)
....:
sage: cputime()-t
43.200000000000045

Since this looks like it's scaling linearly, it looks like it'd take
about 12,000 years to go up to 10^18.

--Mike


--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to