Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int div_count(int);
- int ffun();
- int dfun();
- int wfun();
- int main()
- {
- //int i,t_div_count,p_div_count,t_max, p_max,n =1000;//
- //how many dividers: temp - t_div_count, perm - p_div_count
- //max: temp - t_max perm - p_max
- //t_div_count = p_div_count = t_max = p_max = 0;
- int fdw;
- printf("Chose 1 for using FOR\n2 for using DO\n3 for using WHILE\n");
- scanf("%d",&fdw);
- switch(fdw)
- {
- case 1:ffun();break;
- case 2:dfun();break;
- case 3:wfun();break;
- }
- return 0;
- }
- int dfun()
- {
- int i, t_div_count,p_div_count,p_max ,n = 1000;
- p_div_count = p_max = i = 1;
- do
- {
- t_div_count = div_count(i);
- if(t_div_count>p_div_count)
- {
- p_div_count = t_div_count;
- p_max = i;
- printf("p_div_count-%d p_max-%d\t\t",p_div_count,p_max);
- }
- i++;
- }while(i<n);
- }
- int wfun()
- {
- int i, n, t_div_count,p_div_count,p_max = 0;
- i = 1;
- n=1000;
- while(i<=n)
- {
- t_div_count = div_count(i);
- if(t_div_count>p_div_count)
- {
- p_div_count = t_div_count;
- p_max = i;
- printf("p_div_count-%d p_max-%d\t\t",p_div_count,p_max);
- }
- i++;
- }
- }
- int ffun()
- {
- int i, n, t_div_count,p_div_count,p_max = 0;
- n=1000;
- for(i=1;i<=n;i++)
- {
- t_div_count = div_count(i);
- if(t_div_count>p_div_count)
- {
- p_div_count = t_div_count;
- p_max = i;
- printf("p_div_count-%d p_max-%d\t\t",p_div_count,p_max);
- }
- }
- }
- int div_count(int number)
- {
- int i,div = 1;
- for(i=2;i<=number;i++)
- {
- if(number%i==0)
- {
- div++;
- number/=i;
- i--;
- }
- }
- return div;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement