#include <stdio.h>
/*
This program finds the factors of a number.
*/
int main (void){
	//Declare a variable to hold the number.
	int number;

	//Ask the user to give me the number they want to find the factors of.
	printf("What number would you like to find the factors of?");
	
	//Get user input from the command line.
	scanf("%d",&number);

	
	//Start with the number 1.
	int currFactor = 1;

	//Count up from 1 to the number / 2, since we're finding the factor pairs.
	for (currFactor = 1; currFactor <= number / 2; currFactor++){

		//Divide the number the user gave us by the current factor number we're looking at.
		float otherFactor = number / currFactor;

		//Typecast the otherFactor into an integer. This will take away the decimal part
		//since a typecast truncates.
		int otherFactorInt = (int)otherFactor;

		//Now I will subtract the integer part of the other factor from the floating point other factor.
		float difference = otherFactor - otherFactorInt;

		//If the difference is 0, then that means that otherFactor is a whole number.
		//So, that means that currFactor and otherFactor are factors of number.
		if (difference == 0){

			//Print out the two factors.
			printf("%d times %d is %d\n",currFactor, (int) otherFactor, number);

		}
	}
	return 0;
}
