Hi i need some help with my Java code. I cant seem to get it to work. I am trying to do the birthday paradox and my code keeps messing up and giving me "NaN". Can someone please help me?


Java Code:
    public static void main(String []args)
    {
        int y;
        Scanner keyboard = new Scanner(System.in); //Scanner so we can type a custom input
        System.out.println("Press 1 to use the paradox. Press 2 to use the paradox extended"); //Asks you to enter your speed
        y = keyboard.nextInt(); //Lets the user input there speed.
        if(y == 1)
        {
            double n, a, p, m, k; //Initaites the variable "speed"
            Scanner keyboard1 = new Scanner(System.in); 
            System.out.println("Enter the amount of people in the room"); 
            n = keyboard.nextDouble(); //Lets the user input there speed.
            System.out.println("Enter the amount of days");
            p = keyboard.nextDouble();
            System.out.println("Enter the days again");
            m = keyboard.nextDouble();
        {
            if (m < 0)                             
              System.out.println(0.0);                          
            double fact = 1.0;                    
            while(m > 1) 
            {                         
                 fact = fact * m;                     
                 m = m - 1;                           
            }                                     
              System.out.println("Test value: " + fact);
              System.out.println("Test value: " + p);
              double t = (p - n);
              System.out.println("Test value T: " + t);
            if (t < 0)                             
              System.out.println(0.0);                        
            double fact1 = 1.0;                    
            while(t > 1) 
            {
                 fact1 = fact1 * t;
                 t = t - 1; 
            }
            System.out.println("Test again: " + fact1);
            double l = Math.pow(p, n);
            System.out.println("Test interger: " + l);
            double j = (fact1 * l);
            System.out.println("Test interger: " + j);
            double finish = (fact/j);
            System.out.println("Final value: " + finish);
            double testf = (finish*100);
            System.out.println("Test finish: " + testf);
      
        }    
             
        
        
        }
        
    }

}
Someone please help me...Thanks.