
{"id":16059,"date":"2014-11-18T14:34:33","date_gmt":"2014-11-18T14:34:33","guid":{"rendered":"http:\/\/www.beautifulwork.org\/?p=16059"},"modified":"2014-11-18T14:34:33","modified_gmt":"2014-11-18T14:34:33","slug":"how-to-write-a-program-to-solve-project-euler-problem-10","status":"publish","type":"post","link":"https:\/\/www.trueangle.org\/index.php\/2014\/11\/18\/how-to-write-a-program-to-solve-project-euler-problem-10\/","title":{"rendered":"How to write a program to solve project euler problem 10 ?"},"content":{"rendered":"<pre>\n\/\/ Louis Casillas, oxaric@gmail.com \n\/\/ Further Edits: Fahad Uddin\n\/\/ Modified a little by Jeffrin Jose T \n\/\/ Euler Problem #10\n\/\/ Find the sum of all the primes below two million.\n\n#include \n#include \nchar isPrime( int num )\n{\n   if ((num % 3) == 0 )\n   {\n      return 0;\n   }\n\n   int i = 0;\n   int r = floor ( sqrt( num ) );\n\n   int f = 5;\n   while (f &lt;= r)\n   {\n      if ((num % f) == 0)\n      {\n         return 0;\n      }\n      if ((num % (f + 2)) == 0)\n      {\n         return 0;\n      }\n      f += 6;\n   }\n   return 1;\n}\n#define UPTO 2000000\nint main(void)\n{\n   int i = 5;\n   double sum_of_primes = 5;\n   while (i &lt; UPTO)\n   {\n      if ( isPrime( i ) )\n      {     \n         sum_of_primes += i;\n      }\n      i += 2;\n   }\n   printf( &quot;The sum of the primes is: %f \\n&quot;, sum_of_primes );\n   return 0;\n}\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\/\/ Louis Casillas, oxaric@gmail.com \/\/ Further Edits: Fahad Uddin \/\/ Modified a little by Jeffrin Jose T \/\/ Euler Problem #10 \/\/ Find the sum of all the primes below two million. #include #include char isPrime( int num ) { if ((num % 3) == 0 ) { return 0; } int i = 0; &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.trueangle.org\/index.php\/2014\/11\/18\/how-to-write-a-program-to-solve-project-euler-problem-10\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;How to write a program to solve project euler problem 10 ?&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[3],"tags":[734,1517],"_links":{"self":[{"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/posts\/16059"}],"collection":[{"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/comments?post=16059"}],"version-history":[{"count":0,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/posts\/16059\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/media?parent=16059"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/categories?post=16059"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/tags?post=16059"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}