Project Euler 3 - Highest Prime Factor

前端 未结 2 1040
-上瘾入骨i
-上瘾入骨i 2021-01-28 03:52

before I start I want to clarify that I am not looking for code examples to get the answer; that would defeat the object of Project Euler.

The problem

2条回答
  •  囚心锁ツ
    2021-01-28 04:10

    # Possible solution  but still its *time consuming* but answer can be guessed by the last option in console output 
    
    #include
    #include
    #include
    #include 
    int prime(unsigned long long); 
    using namespace std; 
    int main(){ 
    unsigned long long ii, ij; unsigned long long in; 
    cin>>in; ij = ceil(in/2); 
    if( (ij % 2) == 0 ) ij -= 1; 
    for(ii = 3 ;ii < ij;ii+= 2){
    if(in % ii == 0){
            if(prime(ii) == 1 ){
        cout<<" ans "<

提交回复
热议问题