Ask Your Question

logomath's profile - activity

2023-07-19 10:04:20 +0200 received badge  Popular Question (source)
2023-06-08 16:14:21 +0200 received badge  Famous Question (source)
2023-04-14 10:14:07 +0200 received badge  Popular Question (source)
2023-04-14 10:14:07 +0200 received badge  Notable Question (source)
2023-03-15 07:38:24 +0200 received badge  Notable Question (source)
2022-10-26 11:50:45 +0200 edited question How to eliminate duplicates in a list preserving previous order

How to eliminate duplicates in a list preserving previous order Ex: if A=[1,5,3,3,4,9,9,9,1] I want to obtain [1,5,3,4,

2022-10-26 11:21:51 +0200 received badge  Notable Question (source)
2022-10-26 11:21:51 +0200 received badge  Popular Question (source)
2022-10-26 11:19:06 +0200 received badge  Popular Question (source)
2022-10-26 11:07:40 +0200 edited question How to eliminate duplicates in a list preserving previous order

How to eliminate duplicates in a list preserving previous order Ex: if A=[1,5,3,3,4,9,9,9,1] I want to obtain [1,5,3,4,

2022-10-26 11:07:10 +0200 edited question How to eliminate duplicates in a list preserving previous order

How to eliminate duplicates in a list preserving previous order Ex: if A=[1,5,3,3,4,,9,9,9,1] I want to obtain [1,5,3,4

2022-10-26 11:07:05 +0200 edited question How to eliminate duplicates in a list preserving previous order

How to eliminate duplicates in a list preserving previous order Ex: if A=[1,5,3,3,4,,9,9,9,1] I want to obtain [1,5,3,4

2022-10-26 11:05:53 +0200 asked a question How to eliminate duplicates in a list preserving previous order

How to eliminate duplicates in a list preserving previous order Ex: if A=[1,5,3,3,4,,9,9,9,1] I want to obtain [1,5,3,4

2022-03-05 11:22:31 +0200 received badge  Popular Question (source)
2022-03-05 09:27:40 +0200 asked a question Is there any extrapolation method already implemented in Sage?

Is there any extrapolation method already implemented in Sage? Something like Aitken extrapolation, or Richardson extrap

2021-11-16 22:38:05 +0200 received badge  Famous Question (source)
2021-09-04 03:18:36 +0200 received badge  Famous Question (source)
2020-07-16 09:07:17 +0200 received badge  Famous Question (source)
2020-07-16 09:05:12 +0200 received badge  Popular Question (source)
2020-06-02 18:55:08 +0200 received badge  Famous Question (source)
2020-04-26 21:21:40 +0200 received badge  Notable Question (source)
2020-01-15 18:45:26 +0200 received badge  Notable Question (source)
2020-01-15 18:45:26 +0200 received badge  Popular Question (source)
2019-10-27 10:39:24 +0200 received badge  Notable Question (source)
2019-10-24 14:51:44 +0200 received badge  Famous Question (source)
2019-08-02 09:28:42 +0200 received badge  Notable Question (source)
2019-04-26 22:47:59 +0200 received badge  Notable Question (source)
2019-03-07 16:48:44 +0200 received badge  Notable Question (source)
2019-02-17 20:44:20 +0200 received badge  Popular Question (source)
2019-01-03 09:02:47 +0200 commented answer List creation with local variables

Thank you!

2019-01-02 20:41:24 +0200 commented answer List creation with local variables

Wow! Thank you

2019-01-02 14:25:00 +0200 commented question List creation with local variables

I tried this

%timeit

pp=previous_prime;

w=[n for n in prime_range(5,1000) for m in prime_range(n//2,n) for k in prime_range(m//2,m) if m==pp(n) and k==pp(m) and (n+m+k).is_prime()];

(5 loops, best of 3: 861 ms per loop)

It works, but it is way slower than the original here:

%timeit

pp=previous_prime;

w=[n for n in prime_range(5,1000) if (n+pp(n)+pp(pp(n))).is_prime()];

(125 loops, best of 3: 1.61 ms per loop)

2019-01-02 13:35:43 +0200 commented question List creation with local variables

For example in place of

pp=previous_prime;

w=[n for n in prime_range(5,100) if (n+pp(n)+pp(pp(n))).is_prime()];

I wold like to write something like this:

w=[n for n in prime_range(5,100) if (n+m+k).is_prime() "where" m=pp(n) and k=pp(m)];

Is that possible in some way?

2019-01-02 13:33:53 +0200 asked a question List creation with local variables

Can one create a list with some assumptions inside [ ], without having to make loops?

2019-01-02 13:30:30 +0200 asked a question List creation with assumptions

I would like to create a list with one or more assumptions, without making loops.

2018-11-27 05:33:29 +0200 commented question Finding coprime integers near a lattice point

I mean that (1275,1309) is a solution for the same problem (with same notations as in my answer) with R=[(-1,-1),(-1,0),(-1,1),(0,-1),(0,0),(0,1),(1,-1),(1,0),(1,1)]

2018-11-27 05:25:59 +0200 commented question How to avoid "flags"?

I mean, if we consider this example, when the flag goes to zero, I would go directly to next n, without the program having to try all other p,q,r, something like the od "goto":

N=100; v=[]   #  v = [n that cannot be written as p*q+q*r+r*p with p,q,r prime]
for n in prime_range(1,N):
    flag=True
    for p in prime_range(2,N):
        for q in prime_range(p,N):
            for r in prime_range(q,N):
                if flag and n==p*q+q*r+r*p:
                    flag=False; print n,p,q,r;  break
   if flag: v.append(n)
print v

How would you write such a program (possibly also with rising exception, which I don't know)?