Project Euler - Problem 003

August 1st, 2007 by Daniel Høyer Iversen

The prime factors of 13195 are 5, 7, 13 and 29.

What is the largest prime factor of the number 317584931803?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
 
#include <iostream>
 
using namespace std;
 
int main ()
{
long long res = 317584931803LL;
 
while(res % 2 == 0)
{
res = res /2;
}
 
for(int i = 1; i*i < res; i+=2){
if(res % i == 0){
res = res / i;
}
}
 
cout << "resultatet er ";
cout << res << "n";
return 0;
}
Do you want to use this code?

0 Responses to “Project Euler - Problem 003”

  1. No Comments

Leave a Response