Skip to content

Instantly share code, notes, and snippets.

@DhruvaG2000
Created July 30, 2020 13:07
Show Gist options
  • Save DhruvaG2000/d7fb475b3f68dd42b547f61d10d7df5c to your computer and use it in GitHub Desktop.
Save DhruvaG2000/d7fb475b3f68dd42b547f61d10d7df5c to your computer and use it in GitHub Desktop.
why wont it run???
/*
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