package com.utilis;

public class Math {
	
	public static int getGCF(int n1, int n2)
	{
		int rem = 0;
		int gcf = 0;
		do
		{
			rem = n1 % n2;
			if (rem == 0)
				gcf = n2;
			else
			{
				n1 = n2;
				n2 = rem;
			}
		}
		while (rem != 0);
		return gcf;
	}

	public static int getLCM(int a, int b)
	{
		int num1, num2;
		if (a > b)
		{
            num1 = a;
            num2 = b;
		}
		else
		{
			num1 = b;
			num2 = a;
		}
		for (int i = 1; i <= num2; i++)
		{
            if ((num1 * i) % num2 == 0)
            {
                    return i * num1;
            }
		}
    	throw new Error("Error in LCM!");
	}
	
	public static int[] getFirstXTriangleNumbers(int x){
		
		int[] nums = new int[x];
		for(int i=0; i<=x; i++){
			int num = x;
			for(int t=num; t>0;t--){
				num+=t;
			}
			nums[x] = num;
		}
		return nums;
	}
	
	public static int[] getXNumbersOfFibonacciSequence(int x){
		
		int[] nums = new int[x];
		nums[0] = 0;
		if(nums.length>=2){
			nums[1] = 1;
		}
		if(nums.length>=3){
			for(int i=2; i<=x; i++){
				nums[i] = nums[i-1] + nums[i-2];
				
			}
		}
		return nums;
		
	}
	
}

@@ -1099,10 +1099,413 @@
 %09%09%0A%09%7D%0A%09%0A
+%09// returns the sum of all integers 1 + 2 + .... + n-1 + n%0A%09public static int sum(int n)%0A%09%7B%0A%09%09if( n == 1)%0A%09%09%09return 1;%0A%09%09return n + sum(n-1);%0A%09%7D%0A%09%0A%09// returns n factorial%0A%09public static int fact(int n)%0A%09%7B%0A%09%09if (n == 1)%0A%09%09%09return 1; %0A%09%09return n * fact(n-1);%0A%09%7D%0A%09%0A%09// returns n1 raised to the n2 power%0A%09public static int pow(int n1, int n2)%0A%09%7B%0A%09%09if(n2==1)%0A%09%09%09return n1;%0A%09%09return n1 * pow(n1,n2 - 1);%0A%09%7D%0A%09%0A
 %7D%0A

Update src/com/utilis/Math.java