• 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
  • problem3
  • prog3.c
  • 3 problems has been added · 7e0616b5
    7e0616b5 Browse Directory
    Jim authored 2014-09-24 15:09:38 +0400
prog3.c 365 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>
#include <math.h>

#define NUMBER 600851475143

void primefactors(long int n){

	long int i;

	while (n % 2 == 0){
		printf ("1 %i\n" , 2);
		n = n/2;
	}

	for (i=3; i <= sqrt(n); i= i+2){
		while (n % i == 0){
			printf("2 %li\n", i);
			n = n/i;
		}
	}

	if (n > 2)
		printf ("3 %li\n", n);
}


main () {

	primefactors (NUMBER);

	return 0;
}