/**
 * This exercise is designed to help physical therapists track a patient's range of motion progress over time.
 * The objective is to calculate the difference in motion achieved after performing a set of exercises.
 *
 * @param currentPosition The current position of the patient's joint.
 * @param targetPosition The target position the patient needs to reach.
 * @param exercisesPerformed The number of exercises performed by the patient.
 * @return The difference in motion achieved after performing the exercises.
 *
 * Break Statement:
 * - The break statement will be used to exit the loop if the currentPosition becomes less than or equal to the targetPosition.
 *
 * Subtraction:
 * - Subtraction will be used to calculate the difference between the currentPosition and targetPosition.
 *
 * Difficulty Level: Difficult
 */
fun calculateRangeOfMotion(currentPosition: Double, targetPosition: Double, exercisesPerformed: Int): Double {

    var currentPos = currentPosition
    var difference = 0.0

    repeat(exercisesPerformed) {
        // Calculate the motion achieved after each exercise
        difference = targetPosition - currentPos
        currentPos += difference

        if (currentPos <= targetPosition) {
            return difference
        }
    }

    return difference
}
/**
 * This exercise is designed to help physical therapists track a patient's range of motion progress over time.
 * The objective is to calculate the difference in motion achieved after performing a set of exercises.
 *
 * @param currentPosition The current position of the patient's joint.
 * @param targetPosition The target position the patient needs to reach.
 * @param exercisesPerformed The number of exercises performed by the patient.
 * @return The difference in motion achieved after performing the exercises.
 *
 * Break Statement:
 * - The break statement will be used to exit the loop if the currentPosition becomes less than or equal to the targetPosition.
 *
 * Subtraction:
 * - Subtraction will be used to calculate the difference between the currentPosition and targetPosition.
 *
 * Difficulty Level: Difficult
 */
fun calculateRangeOfMotion(currentPosition: Double, targetPosition: Double, exercisesPerformed: Int): Double {
/**
 * This exercise is designed to help physical therapists track a patient's range of motion progress over time.
 * The objective is to calculate the difference in motion achieved after performing a set of exercises.
 *
 * @param currentPosition The current position of the patient's joint.
 * @param targetPosition The target position the patient needs to reach.
 * @param exercisesPerformed The number of exercises performed by the patient.
 * @return The difference in motion achieved after performing the exercises.
 *
 * Break Statement:
 * - The break statement will be used to exit the loop if the currentPosition becomes less than or equal to the targetPosition.
 *
 * Subtraction:
 * - Subtraction will be used to calculate the difference between the currentPosition and targetPosition.
 *
 * Difficulty Level: Difficult
 */
fun calculateRangeOfMotion(currentPosition: Double, targetPosition: Double, exercisesPerformed: Int): Double {

    var currentPos = currentPosition
    var difference = 0.0

    repeat(exercisesPerformed) {
        // Calculate the motion achieved after each exercise
        difference = targetPosition - currentPos
        currentPos += difference

        if (currentPos <= targetPosition) {
            return difference
        }
    }

    return difference
}