/*
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<>();
        int H=0;   //this will be calculated total beads
        int N=4;   //need to figure limit out pripoerly later
        int M;  //length middle dissector
        int 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=1;i<N;i++)
            {
                M=(i*2)-1;
                
            
                //if (i!=0)
                //{
                    System.out.println("\nMiddle disector: " + M);
                    
                //}
                
                
         R=i-1;
         System.out.println("Number rows above or below: " + R);
                
                
                //go each row above or below disector
                //we expect the value to be
                
                for (int k=1; k<=R;k++)
                {
                    System.out.println("Total full count: " + Permutations(mp,i,M,k,R));
                }
            }
            
       // }while (H<=n);
    }
    
    public static long Permutations (Map factorialResults, int i, int M, int k,int R)
    {
        long result=0;
        
        if (R==0)
        {
            return result;
        }
        
        if (k>=1)
        {
            System.out.println("BEADS in: " + (k) + " row above disector is: " + (M-k));
            //result=(M-k);
            System.out.println("R:" +R);
            if (R!=1)
            {
                System.out.println("HERE");
                System.out.println("HERE RESULTS: " + result);
                result = ((M-k)+(Permutations (factorialResults,i,M,k,(R-1))));
            }
            else
            {
                result = M-k;
            }
            
            
             System.out.println("nnnRESULT: " + result);
            System.out.println("test:" +R);
            
           
            
            //factorialResults.put((M+k),result);
            
            
            
            //return result;
        }
        System.out.println("RWAC: " + result);
        System.out.println("LEAVE THE IF LOOP: ");
        
    return (result*2)+M;
    }
}