• This project
    • Loading...
  • Sign in

Jim / euler

Go to a project
Toggle navigation Toggle navigation pinning
  • Projects
  • Groups
  • Snippets
  • Help
  • Project
  • Activity
  • Repository
  • Graphs
  • Issues 0
  • Merge Requests 0
  • Wiki
  • Network
  • Create a new issue
  • Commits
  • Files
  • Commits
  • Network
  • Compare
  • Branches
  • Tags
Switch branch/tag
  • euler
  • problem2
  • prog2.c
  • 3 problems has been added · 7e0616b5
    7e0616b5 Browse Directory
    Jim authored 2014-09-24 15:09:38 +0400
prog2.c 360 Bytes
Raw Blame History Permalink
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
#include "stdio.h"

#define STEP 4000000

main () {
	
	long int sum;
	int one, two, three;

	one=1;
	two=2;
	three = 0;
	sum = 0;
	while (two <= STEP){

		three = one + two;
//		printf ("%i,", three);

		if ( (two % 2 ) == 0)
			sum += two;	
//		printf ("sum is now: %lu\n", sum);
		one = two;
		two = three;



	}

	printf ("Sum = %lu\n", sum);

	return 0;
}