#include <stdio.h>
#include <stdbool.h>
#include <math.h>

//The computer is going to guess your number!
//This is Nichomachus' ancient puzzle.

int main(void){

	int r3, r5, r7;

	printf("Think of a number between 1 and 100. Don't tell me what it is!\n");

	printf("Divide your number by 3. Tell me the remainder. ");
	
	scanf("%d",&r3);

	printf("Divide your number by 5. Tell me the remainder. ");

	scanf("%d",&r5);

	printf("Divide your number by 7. Tell me the remainder. ");

	scanf("%d",&r7);


	int result = 70 * r3 + 21 * r5 + 15 * r7;


	while (result >= 105){

		result = result - 105;

	}

	printf("Your number was %d! Type y for yes or n for no: ", result);
	
	int wasRight;

	scanf(" %c",&wasRight);
	

	if (wasRight = 'n'){
		
		printf("What was your number? ");
		
		int realNumber;

		scanf("%d",&realNumber);

		if (realNumber > 100 || realNumber < 1){

			printf("You broke the rules. Your number was less than 1 or greater than 100.\n");

		}

		else{

			if (realNumber % 3 != r3){

				printf("Oops, the remainder of your number divided by 3 is %d, not %d.\n",realNumber % 3, r3);

			}

			if (realNumber % 5 != r5){

				printf("Oops, the remainder of your number divided by 5 is %d, not %d.\n",realNumber % 5, r5);

			}

			if (realNumber % 7 != r7){

				printf("Oops, the remainder of your number divided by 7 is %d, not %d.\n",realNumber % 7, r7);

		}

	}


	return 0;
}
