Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #define NELEMS(x) (sizeof(x) / sizeof((x)[0]))
- void factors(int n, int p[], int j) {
- /// if n is divisible by c, store c, and continue with n/c
- int c;
- for (c=2; c < n; c++) {
- if (c > n) break;
- if (n%c == 0) {
- p[j] = c;
- printf("%d has been added to p t", c);
- printf("n has been reduced to %d t", n/c);
- printf("j is %d n", j);
- j++;
- if (n == c) break;
- factors(n/c, p, j);
- }
- }
- }
- int main() {
- /// set up number to factor, and array to hold factors
- int n = 24;
- int p[n/2];
- int i=0;
- for (i=0; i<NELEMS(p); i++) {
- p[i]=0;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement