Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- three_digits_numbers_2_v1.c
- Task:
- How many three digit integers are divisible by the product of its digits?
- You can find all my C programs at Dragan Milicev's pastebin:
- https://pastebin.com/u/dmilicev
- */
- #include <stdio.h>
- int main(void)
- {
- int h, t, u, number, number_of_solutions=0, number_of_iterations=0;
- for(h=1; h<10; h++)
- {
- for(t=1; t<10; t++)
- for(u=1; u<10; u++)
- {
- number_of_iterations++;
- number = 100*h + 10*t + u;
- if( ( number%(h*t*u) )==0 )
- {
- number_of_solutions++;
- printf(" %d%d%d", h, t, u );
- }
- }
- }
- if( number_of_solutions == 0 )
- printf("\n There is no such numbers. \n");
- else
- printf("\n\n There are %d such numbers. \n", number_of_solutions );
- printf("\n Number of iterations %d. \n", number_of_iterations );
- return 0;
- } // main()
Add Comment
Please, Sign In to add comment