Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- numbers_divisible_by_all_digits_1-9.c
- Find all positive integers divisible by all digits 1,2,3,4,5,6,7,8,9.
- You can find all my C programs at Dragan Milicev's pastebin:
- https://pastebin.com/u/dmilicev
- */
- #include <stdio.h>
- #include <limits.h> // for USHRT_MAX = 65535
- int main(void)
- {
- int i, counter=0;
- for ( i=1; i<USHRT_MAX; i++)
- {
- if ( (i%1 + i%2 + i%3 + i%4 + i%5 + i%6 + i%7 + i%8 + i%9) == 0 )
- {
- counter++;
- printf("\n %3d. \t %5d \n", counter, i );
- }
- }
- printf("\n\n There are %d such numbers. \n\n", counter );
- return 0;
- } // main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement