/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package core;

/**
 *
 * @author jirka
 */
public class ExMath
{
        static public int GCD(int a, int b)
        {
            int s = a<b? a : b;
            int gcd = 1;

            for (int i=1; i<=s; i++)
            {
                if (a%i==0 && b%i==0) gcd = i;
            }

            return gcd;
        }

        static public int LCM(int a, int b)
        {
            double dLcm = Math.abs(a*b) / GCD(a, b);
            int lcm = (int) dLcm;
            return lcm;
        }

        static  public Double myExp(int a, int exp)
    {
        Double res = 1.0;
        for (int i=exp; i>0; i--)
            res *= a;
        return res;
    }

        static public int Exp(int a, int exp) {
        int res = 1;
        for (int i = exp; i > 0; i--) {
            res *= a;
        }
        return res;
    }

        static double GetMessageASCII(String msg)
        {
            // udelat retezec ascii kodu a pouzit jako cislo
            // omezit delku na 3 znaky

            for ( int i=0; i<msg.length(); i++)
            {

            }

            return 0;
        }

      static public boolean isPrime(Integer no) {
        if (no < 1) {
            return false;
        }

        int testNo = 2;

        while (testNo < no) {
            if (no % testNo == 0) {
                return false;
            }
            testNo++;
        }
        return true;
    }
}
