Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <limits.h>
- #include <stdlib.h>
- int main(int argc, char *argv[]) {
- int input,inputStart, temp, erg[200];
- int i = 2, j = 0, k;
- input = atoi(argv[1]);
- inputStart = input;
- if(argc != 2) {
- printf("Falsche Argumentzahl\n");
- return 1;
- }
- while(1) {
- if(input == 1)
- break;
- if(input%i == 0) {
- input /= i;
- erg[j++] = i;
- }else if(input%i != 0) {
- i = nextPrim(i);
- }
- //printf("j: %d, Input: %d ", j, input);
- }
- printf("%d: ", inputStart);
- for(k = 0; k < j; k++) {
- printf("%d ", erg[k]);
- }
- printf("\n");
- return 0;
- }
- int nextPrim(int start) {
- int prim, i, j, check;
- for(i=start+1; i <= UINT_MAX; i++) {
- for(j=2; j<i;j++) {
- if(i%j == 0) {
- check = 0;
- break;
- }else {
- check = 1;
- }
- }
- if(check == 1) {
- prim = i;
- break;
- }
- }
- return prim;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement