Created
July 30, 2020 13:07
-
-
Save DhruvaG2000/d7fb475b3f68dd42b547f61d10d7df5c to your computer and use it in GitHub Desktop.
why wont it run???
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
PROBLEM 3 | |
The prime factors of 13195 are 5, 7, 13 and 29. | |
What is the largest prime factor of the number 600851475143 ? | |
*/ | |
#include<iostream> | |
#include<stdint.h> | |
using namespace std; | |
int main(){ | |
cout << "Enter upto which number yuou want to check prime numbers "; | |
unsigned long long int limit=600851475143, factor_count=0; | |
for (long long i = limit; i >= limit/1000; i--) | |
{ | |
factor_count=0; | |
// cout << " " << i << " "; | |
for (long long j = 2; j < i; j++) | |
{ | |
if(i%j==0) | |
{ | |
++factor_count; | |
} | |
} | |
if (factor_count==0 )//&& limit%i==0) | |
{ | |
cout << " " << i ; | |
if(limit%i==0) | |
{ | |
cout << "LARGST = " << i; | |
break; | |
} | |
} | |
} | |
cout<<"prime number out" << limit<<"\n"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment