Ask Your Question

brennan's profile - activity

2024-03-18 17:52:47 +0200 asked a question ternary recurrence sequence

ternary recurrence sequence Is there a built in general recurrence sequence function like the binary recurrence sequence

2023-11-28 21:36:17 +0200 received badge  Notable Question (source)
2023-11-28 21:36:17 +0200 received badge  Popular Question (source)
2023-11-25 17:43:13 +0200 received badge  Notable Question (source)
2023-05-26 20:48:56 +0200 marked best answer Partitions into distinct primes OEIS:A000586

Hello, I am trying to return the number of partitions of $n$ into distinct primes, OEIS A000586. I tried copying the python example from the OEIS, changing "primerange" to "Primes" but got an error

def a(n,k=None):
    if k==None: k=n
    if n<1: return int(n==0)
    return sum(a(n-p,p-1) for p in Primes(1,k+1)
for n in srange(1,50):
    print(n,a(n))

I would really appreciate some help. Thank you!

2023-05-26 11:46:25 +0200 commented answer Partitions into distinct primes OEIS:A000586

Thank you so much! I see the prime_range now, thanks!!

2023-05-26 11:00:05 +0200 asked a question Partitions into distinct primes OEIS:A000586

Partitions into distinct primes OEIS:A000586 Hello, I am trying to return the number of partitions of $n$ into distinct

2023-04-30 15:24:12 +0200 asked a question Partitions into perfect kth prime powers

Partitions into perfect kth prime powers I am trying to return partitions of $n$ into perfect $k$th powers of primes, ca

2023-02-10 15:54:29 +0200 commented answer Binary partition function

Excellent, thank you so much! And that is perfect, I am starting to see how this works. I am having some trouble with on

2023-02-10 15:53:43 +0200 commented answer Binary partition function

Excellent, thank you so much! And that is perfect, I am starting to see how this works. I am having some trouble with on

2023-02-09 12:20:35 +0200 commented answer Binary partition function

This is perfect. Again thank you so much. I am trying now to get the terms of OEIS A025065, partitions into palindromes.

2023-02-09 12:19:40 +0200 commented answer Binary partition function

This is perfect. Again thank you so much. I am trying now to get the terms of OEIS A025065, partitions into palindromes.

2023-02-09 12:19:00 +0200 commented answer Binary partition function

This is perfect. Again thank you so much. I am trying now to get the terms of OEIS A025065, partitions into palindromes.

2023-02-09 12:18:25 +0200 commented answer Binary partition function

This is perfect. Again thank you so much. I am trying now to get the terms of OEIS A025065, partitions into palindromes.

2023-02-09 12:17:11 +0200 commented answer Binary partition function

This is perfect. Again thank you so much. I am trying now to get the terms of OEIS A025065, partitions into palindromes.

2023-02-08 13:53:05 +0200 commented answer Binary partition function

This is perfect, thank you so much! I cannot tell you how helpful this is! I have one more if that is ok. I am trying to

2023-02-08 06:05:53 +0200 commented answer Binary partition function

Thank you so much! And yes, I missed that, good catch! Do you think it would be possible to modify this code slightly t

2023-02-08 06:05:41 +0200 commented answer Binary partition function

Thank you so much! And yes, I missed that, good catch! Do you think it would be possible to modify this code slightly t

2023-02-08 06:04:57 +0200 commented answer Binary partition function

Thank you so much! And yes, I missed that, good catch! Do you think it would be possible to modify this code slightly t

2023-02-07 14:13:34 +0200 asked a question Binary partition function

Binary partition function Hello, I am trying to figure out how to return the number of partitions of n as powers of 2 (s

2022-12-24 12:05:33 +0200 commented answer Log concavity of the power partition function

This is perfect, thank you so much! (and yes, both comments are true, sorry for the confusion!)

2022-12-15 15:46:11 +0200 asked a question Log concavity of the power partition function

Log concavity of the power partition function Recently I proved that the power partition function is log concave. The po

2022-09-27 12:14:06 +0200 asked a question Partition n into perfect kth powers

Partition n into perfect kth powers Hello! I need help writing something that partitions $n$ into perfect $k$th powers (

2022-06-06 17:53:15 +0200 received badge  Popular Question (source)
2022-03-02 10:17:29 +0200 received badge  Good Question (source)
2022-03-02 08:34:10 +0200 received badge  Nice Question (source)
2022-03-02 06:22:25 +0200 asked a question primes of the form (p^q-q^p)/2 bad syntax?

primes of the form (p^q-q^p)/2 bad syntax? I am trying to make a really simple code to get a list of primes n of the for

2021-08-01 03:39:33 +0200 asked a question Finding a sum of two squares that is itself the sum of two squares

Finding a sum of two squares that is itself the sum of two squares I am trying to write something that has a variable d

2020-10-29 14:20:44 +0200 asked a question Extracting gaps between prime terms in a sequence

I am trying to graph and extract the the 'gaps' between prime terms in the sequence:

a(1)=1

a(2)=2

for n>2, a(n)=2a(n-1) if a(n-1) is prime and a(n)=a(n-1)-1 if a(n-1) is not prime.

First of all, I can't even get the sequence to work. I am using:

 P=Primes();
 for n in srange(3,1000):
      if n in P:
           print(2n)
      elif n not in P:
           print(n-1)

But I am getting a syntax error. I am not sure why.

Secondly, I would like to graph this sequence, but I cannot even get it to run.

Lastly, I really want to take this sequence and find the number of non-prime terms between two consecutive prime terms. I just want to print the length of the 'gap' between the prime entries in the sequence. For instance:

The sequence starts 1,2,4,3,6,5,10,9,8,7,14,13,26,25,24,23,46,45,44,43,86,85,84,83,166,165,164,163,326,...

So the first few 'gaps' would just be 1,1,3,1,3,3,3,3,9,3,3,15,...

Any help would be greatly appreciated!

2020-10-21 13:46:56 +0200 asked a question search in a narrow range of values using IntegerListsLex

Hello everyone,

I am having trouble finding solutions to a system of equations because the search involves so many variables that the computation time is large. I am using

for A in IntegerListsLex(length=30, min_part=0, max_part=100, min_slope=0): 

     if...(properties of A):

          print(A)

The problem is it is searching through a bunch of values that I know don't need to be there. How can I get rid of particular search values, like say I want to avoid ever using the numbers 7,11,13 can I somehow remove them from the search parameters?

Thank you all so much!!!

2020-09-29 10:24:15 +0200 asked a question too many for loops

I am trying to solve a Diophantine system with more than 20 variables. I have been trying to use:

\

 for a in srange(1,100):
      for b in srange(1,a+1):
           .
           .
           .
                if (a+b+...)^(1\2) in ZZ and if (a+b+...)^(1/3) in ZZ:
                     print(a,b,...)

The problem is I have more than 20 variables and hence more than 20 of these for loops and Python doesnt allow that. Any help on an easy workaround would be greatly appreciated! This is not for homework or anything, I am just trying to do some computational research on Diophantine systems and I am running into some trouble.

2020-09-23 09:28:45 +0200 commented answer search for values in discrete range

Thank you so much!

2020-09-23 02:29:57 +0200 asked a question search for values in discrete range

I am trying to search for solutions to a pair of equations but only using a few values. I know which values give the possible answers and I want to skip the computation time associated with checking every single value up within an interval. I am using the simple code:

for a in srange(0,200):
     for b in srange(1,a+1):
          if (a+b).is_square() and (a^2+b^2).is_square():
               print(a,b)

which gives me the solutions I want but it computes every integer solution from 0 to 200. If I know the answers, can I search for the range like

for a in range(9,21,28,36,40,84,112,133,156,160)

and then the same as above, and it will print:

28, 21

40, 9

112, 84

156,133

160,36

Any idea how to make that work? This is not homework or anything, just doing a bit of research and I'm a new. Thanks!!

2020-09-13 10:35:18 +0200 commented answer Solving a Diophantine system

Thank you so much! It is exactly what I needed!!

2020-09-13 10:34:49 +0200 received badge  Scholar (source)
2020-09-13 09:01:45 +0200 commented question Solving a Diophantine system

It is not for homework, I am doing research and I am just trying to find small numerical solutions without using elliptic curves.

I do mean that $a+b+c$, $a^2+b^2+c^2$, and $a^3+b^3+c^3$ are simply perfect squares, not perfect fourths.

And i have been trying to define each as a separate equation but I cant solve for the variables within a range as integers, something like:

for a in range(5000) for b in range(5000) for c in range(5000)

eq1 = a+b+c==x^2 eq2 = a^2+b^2+c^2==y^2 eq3 = a^3+b^3+c^3==z^2

solve([eq1,eq2,eq3],a,b,c,x,y,z)

I know this is not right, I am super new to Sage, please help!

2020-09-13 03:45:43 +0200 received badge  Student (source)
2020-09-13 00:28:35 +0200 asked a question Solving a Diophantine system

I am trying to find solutions to the following Diophantine system:

a+b+c=x^2

a^2+b^2+c^2=y^2

a^3+b^3+c^3=z^2

where a,b,c are less than 5000 and where x,y,z are perfect squares