So...i have to make a program that impruves the goldbich theory.
This theory says that every number can be the addition of two smaller numbers.
45:23+22. 12:4+8
And i stuck at this point! If there are a lot of additions i have to show only the one that has the smallest number of the firs. 4+8 3+9 2+10! It has to show the 2+10...
This theory says that every number can be the addition of two smaller numbers.
[...]i have to show only the one that has the smallest number of the firs
Do you mean Goldbach's conjecture? http://en.wikipedia.org/wiki/Goldbach%27s_conjecture because that's a REAL math problem. If not please link to Wikipedia or some other source so that we can better understand what we are trying to accomplish.
For now I'll chalk it up to not typing a clear description of the problem, if this is not the case then "Prove That Addition Exists" is the dumbest f---ing assignment I have ever heard.
Yes this is the theory. I have to pruve it! It s exactly like i made it... but i stuck at this point. I have to output the smallest number of the addition! for example....: P1+P2=N.
Should apply P1 + P2 = N. If there are many solutions it has to print the smaller P1.
The smallest P1 will ALWAYS BE 2 according to this conjecture.
P1 will always be 2 and P2 will always be N - P1.
Which is what I said in my first post to this thread, this is the dumbest assignment I have ever seen, I have no idea what they are trying to teach you about programming.
Ok. Thats true! But when i try after the rundom numbers to put [p<=3] it doesnt do anything.
It still get the rundom numbers and not the p<=3!
Where to put it???
@Computergeek01
I dont think so... it has very good logical thinking... P1 is not 2, it can be any Prime... i suggest rafailos that you do this on your own, so you will gain the best experience through the assignment.. i love things like this... try to do this on your own and feel the joy of it....
EDIT
--------------------------
Goldbach's conjecture is one of the oldest unsolved problems in number theory and in all of mathematics. It states:
Every even integer greater than 2 is a Goldbach number, a number that can be expressed as the sum of two primes.[1]
The number of ways an even number can be represented as the sum of two primes[2]
Expressing a given even number as a sum of two primes is called a Goldbach partition of the number. For example,
i guess thats a bad idea.. how do you define "relevant primes".. you will need all the primes.. infinite number of primes... but in the other way you are correct that you store the smallest primes in an array ( i prefer using unsigned short integers for saving space and time ), so that you dont have to calculate the same old primes ( 2, 3, 5 , 7.... until about 101 )..
http://en.wikipedia.org/wiki/List_of_prime_numbers
this link will give you the first 500 primes i guess.. i recommend that you dont waste your time finding the rest because u will get sic of typing numbers, and any typing mistake you make will take you to hell...
this is a simple idea... you can use this or enhance this....
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
while(1){
Number - APrimeSmallerThanNumber == X;
if ( X is a prime )
{
/* you win */
}
elseif ( there are more primes which are smaller that Number )
{
/* try next prime which is smaller than array */
}
else
{
/* something wrong with goldbatch or me..!!! :P */
}
}
the simple words as cooments and expressions such as "X is a prime", " try next prime" will be real pain to implement...
i wish you all the best...
how do you define "relevant primes".. you will need all the primes.. infinite number of primes...
If you want to test the golbach conjeture to numbers up to 1000000 you don't need primes greater that 1000000. In fact you only need the primes up to sqrt(1000000) = 1000. Those are the "relevant primes".
this link will give you the first 500 primes i guess.. i recommend that you dont waste your time finding the rest because u will get sic of typing numbers, and any typing mistake you make will take you to hell...
Then don't type them, but compute them instead.
I use the definition
_A number is prime if it cant be divided by any prime number less than or equal to its square root.
_2 is a prime number.
Because of memory ussage, instead of erasing the numbers that are not primes, insert the numbers that are.
So I start wiht a vector that has only the 2. Then test for modulo for every odd number against the numbers in the vector.
If it is a prime number, added to the vector and continue.
Now implementing X is prime, will be a search in an sorted array or use the definition again.
And try next prime will be prime_index++
yes ne555,
thats all what i meant, and also what i say is that you can type the little primes to an array just like you said earlier, so you would be saving some time cost of processer for finding those primes, and when you want to find the other primes ( greater than those in the array) you can calculate according to the definition of the primes..
i said that you will need infinite.. when you dont know the largest number you get to find.. but of course, if you are using unsigned short for example, you know that the largest number is 65536, and you will need not need those primes bigger than that...