In this lecture we looked at how to find the remainder after division and how this can be useful for decision making.
Your challenge is to imagine a 4 player game, and figure out who goes first.
Player 1 is assigned the remainder 0.
Player 2 is assigned the remainder 1.
Player 3 is assigned the remainder 2.
Player 4 is assigned the remainder 3.
To decide who goes first, find the remainder of 63 ÷ 4.
Pop your answer below and then set a new integer (to replace 63) for the next person in the chain to try.
To answer the question, my remainder was 3 so player 4 would start
If the next number was 64 the remainder would be 0 so in the next round player 1 would start
The operations I did on the calculator:
(63 % 4) = ((63 / 4) - 15) * 4 = 3 so player four gets the first turn
my code to solve this assignment:
using UnityEngine;
public class MathCourseTests : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
int remainder = 63 % 4;
Debug.Log("The remainder of 63/4 is: " + remainder);
Debug.Log(“So player " + (remainder + 1) + " goes first”);
}
}