Questions tagged [goldbach-conjecture]

21 questions
3
votes
2 answers

Implementing Goldbach's Conjecture in C code

#include int prime(int num); int main() { int upper, lower, tempL, x; printf("Enter lower limit:"); scanf("%d", &lower); printf("Enter upper limit:"); scanf("%d", &upper); for (lower; lower <= upper; lower + 2)…
Superman
  • 105
  • 1
  • 8
2
votes
1 answer

Problem in writing Goldbach conjecture program

I'm just learning programming and my task was to writce a code in C++ that for given even number would return this number as a sum of two primes. Previously I managed to write a code checking if number is prime or not but as I tried to apply this,…
1qwertyyyy
  • 123
  • 3
2
votes
3 answers

goldbach's conjecture algorithm shows "list index out of range" above a specific number

I am creating a program where the user can enter an even number between 4 and 5000 and the program will output a list of pairs of prime numbers that sum up the number provided in the input. My program works fine to put all the prime numbers in a…
aidan
  • 85
  • 1
  • 2
  • 8
2
votes
2 answers

Checking Goldbach's conjecture holds up to N

I've been asked to write a piece of code that checks that Goldbach's conjecture holds for every even number up to N, so far I have the following: def gb(n): #give a list of all primes less than n using the sieve of Eratosthenes (not considering…
Denis Mclaughlin
  • 53
  • 1
  • 1
  • 8
2
votes
2 answers

Goldbach conjecture exercise (c)

My professor asked me to do a program to test the Goldbach conjecture. I am wondering if I should consider 1 as a prime. This is my code that prints the first combination of prime numbers: #include #include #include…
The Gramm
  • 118
  • 2
  • 12
1
vote
1 answer

Display all prime number pairs whose sum is N

I am working on a code for Goldbach Conjecture to display the prime number pairs whose sum is equal to a positive even number N. I was able to find these prime number pairs but I want to print all these prime number pairs equal to N in one single…
1
vote
1 answer

Goldbach graph using sagemath

I'm learning SageMath (uses Python 3) and playing with the Goldbach conjecture. I wrote this function (it works!): def Goldbach(n): if n % 2 != 0 or n <= 2: show("No és parell") else: for i in srange(n): if…
Oriol
  • 13
  • 2
1
vote
1 answer

Implementing Goldbach's conjecture in Haskell, lots of restrictions

The point of this assignment is to understand list comprehensions. Implementing Goldbach's conjecture for some natural number (otherwise the behavior does not matter) using several pre-defined functions and under the following restrictions: no…
1
vote
9 answers

Goldbach Conjecture in Python

I have attempted to write a code that returns a single pair that satisfies the Goldbach Conjecture for a given N. The conjecture states that every even number greater than 4 can be expressed as the sum of two prime numbers. The function returns a…
jemima
  • 29
  • 1
  • 1
  • 6
1
vote
1 answer

Weak Goldbach Conjecture in python

I've tried to write a code for the weak Goldbach Conjecture, which states that every odd number greater than 5 can be expressed as the sum of three prime numbers. However, the code only returns (0, 0, 0). I only need one triple that works rather…
jemima
  • 29
  • 1
  • 1
  • 6
1
vote
1 answer

Type error: `character_code' expected with prolog

I am new to prolog. I was writing a code with Goldbach’s Conjecture problem which I have to list all possible groups of one even number. I found a code like this: is_prime(2). is_prime(3). is_prime(P) :- integer(P), P > 3, P mod 2 =\= 0, \+…
0
votes
1 answer

Duplicate Pairs while implementing Goldbach Conjecture Implementation in Python

As the title suggests I am working on finding all the pairs of prime numbers that satisfy the goldbachs conjecture for any given number n. This is my implementation of the algorithm: import math def prime(n): for i in…
0
votes
1 answer

Fastest way to count Goldbach Partitions in Pari/GP

I am trying to calculate the number of Goldbach Partitions and hitting a wall when n is large. Any advice on how I can make this code as fast as possible would be helpful. Here is the best I have been able to do so far: n=1000; x=0; forprime(i=n,…
Goldbug
  • 206
  • 2
  • 8
0
votes
1 answer

How do I print the two elements of an array and the subsequent sum of these elements? (Goldbachs Primes Question)

I am trying to solve this problem: Goldbach Conjecture Show with a program "goldbach.py" ​​that all even numbers up to 1000 can indeed be written as the sum of two primes. Specifically: for each even number, also show explicitly (on the screen) that…
DeMelkbroer
  • 629
  • 1
  • 6
  • 21
0
votes
1 answer

In a list of lists, how do I count the amount of equal sums I have in my list?

I am pretty new to Python and struggle to count my amount of equal sums in my list of lists. I create a list of numbers (list oneven), according to Goldbach every number is equal to three Primenumbers. I now have a list of all combination of prime…
Hendrik
  • 45
  • 1
  • 1
  • 7
1
2