Skip to content

Instantly share code, notes, and snippets.

@goyuninfo
Created May 18, 2014 15:52
Show Gist options
  • Select an option

  • Save goyuninfo/c47faca7c6763bf71136 to your computer and use it in GitHub Desktop.

Select an option

Save goyuninfo/c47faca7c6763bf71136 to your computer and use it in GitHub Desktop.
Largest prime factor
def lpf(x):
lpf = 2;
while (x > lpf):
if (x%lpf==0):
x = x/lpf
lpf = 2
else:
lpf+=1;
print("Largest Prime Factor: %d" % (lpf));
def main():
x = long(raw_input("Input long int:"))
lpf(x);
return 0;
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment