Advertisement
Guest User

Untitled

a guest
May 12th, 2013
5,127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.40 KB | None | 0 0
  1. //Project Euler Problem 3 Solution
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4.  
  5. void lpf(long long int x)
  6. {
  7.     long long int lpf = 2;
  8.     while (x > lpf)
  9.     {
  10.         if (x%lpf==0)
  11.         {
  12.             x = x/lpf;
  13.             lpf = 2;
  14.         }
  15.         else
  16.         {
  17.             lpf++;
  18.         }
  19.     }
  20.     printf("Largest Prime Factor: %lld\n",lpf);
  21. }
  22.  
  23. int main ()
  24. {
  25.     long long int x;
  26.     printf("Input long int:\n");
  27.     scanf("%lld",&x);
  28.     lpf(x);
  29.     return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement