Given a range of integers by its lower and upper limit, print a list of all even numbers and their Goldbach composition.
Example:
Input lower limit: 9
Input upper limit: 20
Output:
10 = 3 + 7
12 = 5 + 7
14 = 3 + 11
16 = 3 + 13
18 = 5 + 13
20 = 3 + 17
1
Expert's answer
2012-09-06T10:02:57-0400
int i; int lowerlimit; int upperlimit; onSelfEvent(load){ lowerlimit=9; upperlimit=20;
for(i=lowerlimit;i<=upperlimit;i++){ if (i%2==0){ _root.Show(i); } } }
int j; int N; int primes = 0; int nn=0; int left=0; int right=0; function Show(number ) { isprime = new Array; N = number; for(j=2;j<N;j++){ isprime[j] = "1"; } } for(j=2;j<=N;j++){ if(i*i<N){ if(isprime[j]=="1"){ for(l=j;l<=N;l++){ isprime[i * j] = "0" ; }
Comments
Leave a comment