#include #include #define L 100 main() { long int inp; /*input*/ long int lnp; /*Large Non Prime*/ long double r; /*Root*/ long int fr; /*Floor Root*/ long int cr; /*Ceiling Root*/ long int a; /*result of lnp mod fr*/ long int b; /*result of lnp mod sr*/ long int c; /*counter*/ long int frt; /*fr tester*/ long int z = 1; /*efficiency tester*/ long int e = 0; /* even tester */ printf("number>"); scanf("%d", &inp); lnp = inp; while (e < 1){ /*ferret out all twos*/ e = lnp%2; if ( e == 0) { printf("2 is a factor.\n"); lnp = lnp/2; } } r = sqrt(lnp); /*get starting point*/ fr = floor(r); frt = fr%2; /*make starting point odd*/ if (frt == 0) { fr = fr -1; } c = fr + 2; /*set stop point*/ while (c > 2){ a = lnp%fr; /* printf("%d mod %d = %d", lnp, fr, a); */ if ( a == 0) { /*then it's a factor*/ if (fr > 1) { /*display bullshit*/ printf("%d is a factor. (fr) \n", fr); } cr = lnp/fr; if (cr > 1) { if (cr < lnp) { printf("%d is a factor. (cr) \n", cr); } } if (cr == lnp) { printf("%d is prime. \n", cr); } c = 1; } fr = fr - 2; /*ready for the next step*/ c = c - 2; z = z + 1; /*count steps*/ } printf("That took %d steps.\n", z); }