39 lines
1.1 KiB
C
39 lines
1.1 KiB
C
#include <stdio.h>
|
|
|
|
#define MIN(a,b) (a < b) ? a : b
|
|
#define THOUSAND 1000
|
|
#define TWO 2
|
|
//---------------------------------------------------------------------------------------
|
|
// Exercise 6
|
|
// ----------
|
|
//
|
|
// General : The program prints positive integers that divide the two input
|
|
// numbers in the field up to 1000.
|
|
//
|
|
// Input : Two numbers that don't divide each other.
|
|
//
|
|
// Process : The program do a loop.
|
|
//
|
|
// Output : Positive integers.
|
|
//
|
|
//---------------------------------------------------------------------------------------
|
|
// Programmer : Cohen Idan
|
|
// Student No : None
|
|
// Date : 23.09.2019
|
|
//---------------------------------------------------------------------------------------
|
|
void main(void)
|
|
{
|
|
unsigned short num1,
|
|
num2,
|
|
counter;
|
|
|
|
printf("Enter 2 numbers: ");
|
|
scanf("%hu%hu", &num1, &num2);
|
|
|
|
for (counter = ((MIN(num2, MIN(num1, THOUSAND))) / TWO); counter; counter--)
|
|
{
|
|
if (!((num1 % counter) + (num2 % counter)))
|
|
printf("%hu\n", counter);
|
|
}
|
|
|
|
} |