// 
// Decompiled by Procyon v0.6.0
// 

package com.hypixel.hytale.builtin.hytalegenerator.framework.math;

public class MultipliedIteration
{
    public static double calculateMultiplier(final double startValue, final double endValue, final int numberOfIterations, final double precision) {
        if (startValue < endValue) {
            throw new IllegalArgumentException("start smaller than end");
        }
        if (numberOfIterations <= 0) {
            throw new IllegalArgumentException("number of iterations must be greater than 0");
        }
        if (precision <= 0.0) {
            throw new IllegalArgumentException("precision must be greater than 0");
        }
        double candidate = 0.0;
        int result = 0;
        while (candidate < 1.0) {
            result = calculateIterations(candidate, startValue, endValue);
            if (result >= numberOfIterations) {
                break;
            }
            candidate += precision;
        }
        return Math.min(candidate, 0.99999);
    }
    
    public static int calculateIterations(final double multiplier, final double startValue, final double endValue) {
        double currentSize;
        int iterations;
        for (currentSize = startValue, iterations = 0; currentSize > endValue; currentSize *= multiplier, ++iterations) {}
        return iterations;
    }
}
