Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. #define NELEMS(x) (sizeof(x) / sizeof((x)[0]))
  4.  
  5. void factors(int n, int p[], int j) {
  6. /// if n is divisible by c, store c, and continue with n/c
  7. int c;
  8. for (c=2; c < n; c++) {
  9. if (c > n) break;
  10. if (n%c == 0) {
  11. p[j] = c;
  12. printf("%d has been added to p t", c);
  13. printf("n has been reduced to %d t", n/c);
  14. printf("j is %d n", j);
  15. j++;
  16. if (n == c) break;
  17. factors(n/c, p, j);
  18. }
  19. }
  20. }
  21.  
  22. int main() {
  23. /// set up number to factor, and array to hold factors
  24. int n = 24;
  25. int p[n/2];
  26. int i=0;
  27. for (i=0; i<NELEMS(p); i++) {
  28. p[i]=0;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement