Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <unistd.h>
- #include <string.h>
- #define PERIOD 1000
- void
- wait()
- {/*{{{*/
- usleep(PERIOD);
- }/*}}}*/
- int
- factor(int n)
- {/*{{{*/
- int i = 1,
- factors = 0;
- for(i = 1; i <= n; i++)
- if(n % i == 0)
- factors++;
- return factors;
- }/*}}}*/
- int
- main(int argc, char **argv)
- {/*{{{*/
- int i = 0,
- factors = 0,
- record = 0,
- quiet = 0;
- if(argv[1]){
- if(!strcmp(argv[1], "-q")){
- quiet = 1;
- }
- }
- while(++i){
- factors = factor(i);
- if(!quiet)
- printf("%i: %i", i, factors);
- if(factors > record){
- record = factors;
- if(!quiet)
- printf(" NEW RECORD!");
- else
- printf("%i: %i\n", i, factors);
- }
- if(!quiet){
- printf("\n");
- wait();
- }
- }
- }/*}}}*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement