/*
Online Java - IDE, Code Editor, Compiler
Online Java is a quick and easy tool that helps you to build, compile, test your programs
online.
*/

import java.util.*;

public class Permutation
{
    public static void main(String[] args) 
    {
        System.out.println("Welcome to Online IDE!! Happy Coding :)");
        int n=35;
        Map <Long, Long> mp = new HashMap<>();
        long H=0;   //this will be calculated total beads
        long N=20;   //need to figure limit out pripoerly later
        long M;  //length middle dissector
        long R; //number rows above or below to the dissector
        
        System.out.println("***CENTERED HEXAGONAL NUMBER***");
        System.out.println("P(n,r) = n! / (n−r)!");
        
        //do
    //    {
            //we know n value is too high, but safe measure
            for (int i=0;i<N;i++)
            {
                M=(i*2)-1;
                
                R=i-1;
                
                if (i!=0)
                {
                    System.out.println("Middle disector: " + M);
                    System.out.println("Number rows above or below: " + R);
                }
                
                //go each row above disector
                for (int k=0; k<R;k++)
                {
                    System.out.println(Permutations(mp,i,M,k));
                }
            }
            
       // }while (H<=n);
    }
    
    public static long Permutations (Map factorialResults, int i, long M, int k)
    {
        long result=0;
       
        
        if (i>=1)
        {
            result = ((M+k)+(Permutations (factorialResults,(i-1),M,k)));
            System.out.println("RESULT: " + result);
            factorialResults.put((M+k),result);
            
            
           
            return result;
        }
        
    return 1;
    }
}