[an error occurred while processing this directive]

CMSC201
Programming Project Two

Goldbach's Conjecture

Out: Tuesday 3/4/97
Due: Midnight Tuesday 3/18/97

The Objective

The objective of this assignment is to give you some practice using for loops, using #define for constants, writing functions and formatting output.

The Background

Christian Goldbach did important work in number theory, much of it in correspondence with Euler. He is best remembered for his conjecture, made in 1742 in a letter to Euler and still an open question, that every even integer greater than 2 can be represented as the sum of two primes. Some biographical information on Goldbach:
Born: March 18, 1690 in Konigsberg, Prussia (now Kaliningrad, Russia)
Died: November 20, 1764 in Moscow, Russia
In 1725 Goldbach became professor of mathematics and historian at St. Petersburg. Then, in 1728, he went to Moscow as tutor to Tsar Peter II.

The Task

You are to test out Goldbach's conjecture on the even numbers between 200 and 400. The values 200 and 400 are the constants START and FINISH, respectively. Your program should display the value and the two primes that when added produce that value as their sum. (See the sample run below)

Your output should match the sample run shown below, exactly. There should be 3 values and their primes displayed on each line of output.

You will be expected to use three functions, other than main, when writing your program. Here are the function prototypes:

void PrintExplanation (void); int Goldbach (int n); bool IsPrime (int n);

Function Descriptions:

The Sample Run

umbc9[1]% a.out This program will demonstrate the truth of Goldbach's conjecture for the even integers 200 through 400, inclusive. The conjecture is that any even integer greater than 2 can be expressed as the sum of two prime numbers. 200 = 3 + 197 202 = 3 + 199 204 = 5 + 199 206 = 7 + 199 208 = 11 + 197 210 = 11 + 199 212 = 13 + 199 214 = 3 + 211 216 = 5 + 211 218 = 7 + 211 220 = 23 + 197 222 = 11 + 211 224 = 13 + 211 226 = 3 + 223 228 = 5 + 223 230 = 3 + 227 232 = 3 + 229 234 = 5 + 229 236 = 3 + 233 238 = 5 + 233 240 = 7 + 233 242 = 3 + 239 244 = 3 + 241 246 = 5 + 241 248 = 7 + 241 250 = 11 + 239 252 = 11 + 241 254 = 3 + 251 256 = 5 + 251 258 = 7 + 251 260 = 3 + 257 262 = 5 + 257 264 = 7 + 257 266 = 3 + 263 268 = 5 + 263 270 = 7 + 263 272 = 3 + 269 274 = 3 + 271 276 = 5 + 271 278 = 7 + 271 280 = 3 + 277 282 = 5 + 277 284 = 3 + 281 286 = 3 + 283 288 = 5 + 283 290 = 7 + 283 292 = 11 + 281 294 = 11 + 283 296 = 3 + 293 298 = 5 + 293 300 = 7 + 293 302 = 19 + 283 304 = 11 + 293 306 = 13 + 293 308 = 31 + 277 310 = 3 + 307 312 = 5 + 307 314 = 3 + 311 316 = 3 + 313 318 = 5 + 313 320 = 3 + 317 322 = 5 + 317 324 = 7 + 317 326 = 13 + 313 328 = 11 + 317 330 = 13 + 317 332 = 19 + 313 334 = 3 + 331 336 = 5 + 331 338 = 7 + 331 340 = 3 + 337 342 = 5 + 337 344 = 7 + 337 346 = 29 + 317 348 = 11 + 337 350 = 3 + 347 352 = 3 + 349 354 = 5 + 349 356 = 3 + 353 358 = 5 + 353 360 = 7 + 353 362 = 3 + 359 364 = 5 + 359 366 = 7 + 359 368 = 19 + 349 370 = 3 + 367 372 = 5 + 367 374 = 7 + 367 376 = 3 + 373 378 = 5 + 373 380 = 7 + 373 382 = 3 + 379 384 = 5 + 379 386 = 3 + 383 388 = 5 + 383 390 = 7 + 383 392 = 3 + 389 394 = 5 + 389 396 = 7 + 389 398 = 19 + 379 400 = 3 + 397 umbc9[2]%

Submitting the Program

To submit the file you should use the command:

submit cs201 proj2 proj2.c

You can check your submission by using the command:

submitls cs201 proj2 [an error occurred while processing this directive] Tuesday, 04-Mar-1997 10:54:50 EST