Pastebin launched a little side project called HostCabi.net, check it out ;-)Don't like ads? PRO users don't see any ads ;-)
Guest

My Implementation

By: a guest on Aug 21st, 2013  |  syntax: C  |  size: 0.69 KB  |  hits: 47  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #include <stdio.h>
  2. #include <math.h>
  3. #include <stdlib.h>
  4.  
  5. int main()
  6. {
  7.     int i, j;
  8.     int value;
  9.     int *number_list;
  10.     int largest_prime_factor;
  11.    
  12.     printf("Please enter an Integer\n");
  13.     scanf("%d", &value);
  14.    
  15.     number_list = (int *)malloc((value + 1) * sizeof(int));
  16.    
  17.     for(i = 0; i <= value; i++)
  18.         number_list[i] = 0;
  19.  
  20.     for(i = 2; i <= value; i++)
  21.         if(number_list[i] != 1)
  22.             for(j = 2; (i * j) <= value; j++)
  23.                 number_list[(i * j)] = 1;
  24.    
  25.     for(i = 2; i <= value; i++)
  26.         if(number_list[i] == 0 && value % i == 0)
  27.             largest_prime_factor = i;
  28.  
  29.     printf("%d", largest_prime_factor);
  30. }