0

I am trying to write a recursive function that will produce a fractal snowflake, but am not getting the correct results. For some reason it gets caught in an infinte loop, but I cannot figure out why. Any help is appreciated.

```
private void recursiveDraw(double x1, double y1, double x2, double y2, int orderNum, Graphics gr) {
if (orderNum == 0) {
gr.drawLine((int) x1, (int) y1, (int) x2, (int) y2);
} else {
double x4 = x1 * 2 / 3 + x2 * 1 / 3;
double y4 = y1 * 2 / 3 + y2 * 1 / 3;
double x5 = x1 * 1 / 3 + x2 * 2 / 3;
double y5 = y1 * 1 / 3 + y2 * 2 / 3;
double x6 = (x4 + x5) / 2 + (y4 - y5) * sqrt(3) / 2;
double y6 = (y4 + y5) / 2 + (x5 - x4) * sqrt(3) / 2;
recursiveDraw(x1, y1, x4, y4, orderNum, gr);
recursiveDraw(x4, y4, x6, y6, orderNum, gr);
recursiveDraw(x6, y6, x5, y5, orderNum, gr);
recursiveDraw(x5, y5, x2, y2, orderNum, gr);
}
}
```