Sunday, May 15, 2016

Project Euler Problem 1


This is Problem 1 of Project Euler written in C. Stay tuned to my bitbucket to get more problems to this project written in C and Objective-C. I built this project on my FreeBSD box with clang 3.6.

 void Problem1()  
 {  
   int sum = 0;  
   int i = 0;  
   while (i < 1000)  
   {  
     if (i%3 == 0 || i%5 == 0)   
     {  
       sum += i;  
     }  
     i++;  
   }  
   printf("Sum of all natural numbers below one thousand that are \  
   multiples of 3 or 5 is: %d\n", sum);  
 }