title: Verifying output to "Find the numbers between 1 and 1000 whose prime factors' sum is itself a prime" from Allain's Jumping into C++ (ch7 #3)
body: <p>The question:</p>
  
  <blockquote>
  Design a program that finds all numbers from 1 to 1000 whose prime factors, when added
  together, sum up to a prime number (for example, 12 has prime factors of 2, 2, and 3, which
  sum to 7, which is prime). Implement the code for that algorithm.
  </blockquote>
  
  <p>I modified the problem to only sum unique factors, because I don't see why you'd count a factor twice, as in his example using 12.</p>
  
  <p><a href="https://github.com/evansendra/c-playground/commit/1c427d20c5388bfc2ce8087c225cbbd65ee907e2" rel="nofollow">My solution</a>. Is there any good (read: automated) way to verify the output of my program?  </p>
  
  <p>Sample output for 1 to 1000:</p>
  
  <pre><code>1
  2
  3
  4
  5
  6
  7
  8
  9
  10
  11
  12
  13
  14
  15
  17
  19
  20
  22
  23
  24
  25
  26
  28
  29
  30
  31
  34
  37
  40
  41
  43
  44
  46
  47
  48
  49
  52
  53
  58
  59
  60
  61
  63
  67
  68
  70
  71
  73
  76
  79
  80
  82
  83
  88
  89
  92
  94
  96
  97
  99
  101
  103
  107
  109
  113
  116
  117
  118
  120
  121
  124
  127
  131
  136
  137
  139
  140
  142
  147
  148
  149
  151
  153
  157
  160
  163
  164
  167
  169
  171
  172
  173
  176
  179
  181
  184
  188
  189
  191
  192
  193
  197
  198
  199
  202
  207
  210
  211
  212
  214
  223
  227
  229
  232
  233
  239
  240
  241
  244
  251
  252
  257
  261
  263
  268
  269
  271
  272
  273
  274
  275
  277
  279
  280
  281
  283
  286
  289
  292
  293
  294
  297
  298
  306
  307
  311
  313
  317
  320
  325
  331
  332
  333
  334
  337
  347
  349
  351
  352
  353
  358
  359
  361
  367
  368
  369
  373
  376
  379
  382
  383
  384
  388
  389
  394
  396
  397
  399
  401
  404
  409
  412
  414
  419
  421
  423
  424
  425
  428
  431
  433
  439
  443
  449
  454
  457
  459
  461
  462
  463
  464
  467
  468
  472
  475
  478
  479
  480
  487
  491
  495
  499
  503
  509
  513
  521
  522
  523
  524
  529
  531
  538
  539
  541
  544
  546
  547
  548
  549
  550
  557
  560
  561
  562
  563
  567
  569
  571
  572
  575
  577
  587
  588
  593
  594
  599
  601
  603
  604
  605
  607
  612
  613
  617
  619
  621
  622
  628
  631
  639
  640
  641
  643
  646
  647
  651
  652
  653
  659
  661
  664
  668
  673
  677
  683
  684
  691
  692
  694
  701
  704
  709
  712
  714
  718
  719
  725
  726
  727
  733
  736
  738
  739
  741
  743
  751
  752
  756
  757
  759
  761
  764
  765
  768
  769
  772
  773
  775
  777
  783
  787
  792
  797
  798
  801
  809
  811
  821
  823
  825
  827
  828
  829
  833
  837
  838
  839
  841
  846
  847
  848
  850
  853
  856
  857
  859
  862
  863
  873
  877
  881
  883
  887
  891
  892
  903
  904
  907
  908
  909
  911
  918
  919
  922
  925
  928
  929
  932
  937
  941
  944
  947
  953
  954
  957
  960
  961
  966
  967
  971
  975
  977
  981
  983
  991
  997
  999
  </code></pre>
  
  <p><strong>Update</strong>:  I have solved my problem and verified the output of my program using an <a href="http://oeis.org/A100118" rel="nofollow">OEIS given series</a>, as suggested by @MVW (shown in the source given by <a href="https://github.com/evansendra/c-playground/blob/master/when-you-dont-know/prime_finder.cpp" rel="nofollow">my new github solution</a>).  In the future, I will aim to test my programs by doing zero or more of the following (depending on the scope/importance of the problem):</p>
  
  <ul>
  <li>google keywords for an existing solution to the problem, comparing it against my solution if I find it</li>
  <li>unit test components for correctness as they're built and integrated, comparing these tests with known correct outputs</li>
  </ul>