Skip to content

Instantly share code, notes, and snippets.

@musoftware
Last active August 29, 2015 13:56
Show Gist options
  • Save musoftware/8882897 to your computer and use it in GitHub Desktop.
Save musoftware/8882897 to your computer and use it in GitHub Desktop.
Largest prime factor
#include "stdafx.h"
#include <iostream>
using namespace std;
void main()
{
long int factor = 600851475143;
for (long int divider = 2; divider < factor; divider++)
{
(factor % divider == 0) ? factor /= divider, divider = 2 : NULL;
}
cout << factor << endl;
system("pause");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment