/* autogenerated by Processing revision 1286 on 2022-12-05 */
import processing.core.*;
import processing.data.*;
import processing.event.*;
import processing.opengl.*;

import java.util.HashMap;
import java.util.ArrayList;
import java.io.File;
import java.io.BufferedReader;
import java.io.PrintWriter;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.IOException;

public class sketch_PrimeFactors2 extends PApplet {

int InputNum = 0;
String Inputstr = "";
 public void setup()
{
  textSize(40);
  /* size commented out by preprocessor */;
  textAlign(LEFT);
}
 public void draw()
{
  background(0);
  text("Give me a number to find the Prime factors of: " + Inputstr, 0, 40, 500, 300);
  text(FindPrimeFactors(InputNum).toString(), 0, 300, 500, 500);
}
 public void keyPressed()
{
 if(key >= '0' && key <= '9')
 {
   Inputstr += key;
 }
 if(keyCode == BACKSPACE && Inputstr.length() > 0)
 {
  Inputstr = Inputstr.substring(0, Inputstr.length() - 1);
 }
 InputNum = PApplet.parseInt(Inputstr);
}
 public IntList FindPrimeFactors(int MaxNum)
{
  IntList PrimeFactors = new IntList();
  int j = 0;
  for (int i = 2; i <= MaxNum; )
  {
    if (MaxNum % i == 0)
    {
      MaxNum /= i;
      PrimeFactors.append(i);
      j++;
    } else
    {
      i++;
    }
  }
  return PrimeFactors;
}


  public void settings() { size(500, 500); }

  static public void main(String[] passedArgs) {
    String[] appletArgs = new String[] { "sketch_PrimeFactors2" };
    if (passedArgs != null) {
      PApplet.main(concat(appletArgs, passedArgs));
    } else {
      PApplet.main(appletArgs);
    }
  }
}
