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 @ @ ^ @ @ @ ^ @ @ @ ^ ^ ^ @ @ ^ ^ @ @ ^ ^ @ @ ^ ^ @ @ ^ ^ @ @ ^ ^ @ @ ^ ^ @ @ ^ ^ ^ @ ^ @ ^ @ ^ @ ^ @ ^ @ ^ @ ^ @ ^ @ ^ @ ^ @ ^ @ ^ @ ^ @ ^ @ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^

*This Xmas tree is written in Java. If you are interested in code and theory behind the tree structure, please read on.*

# 1. Build Pascal’s triangle

In mathematics, Pascal’s triangle is a triangular array of the binomial coefficients [1].

10-rows Pascal’s triangle has following structure:

1 1 1 1 2 1 1 3 3 1 1 4 6 4 1 1 5 10 10 5 1 1 6 15 20 15 6 1 1 7 21 35 35 21 7 1 1 8 28 56 70 56 28 8 1

# 2. Use Sierpinski triangle

Marking odd numbers in Pascal’s triangle closely resembles the fractal called the Sierpinski triangle [2].

10-rows Pascal’s triangle with odd numbers replaced with **^** and even numbers replaced with **@** looks like the following figure:

^ ^ ^ ^ @ ^ ^ ^ ^ ^ ^ @ @ @ ^ ^ ^ @ @ ^ ^ ^ @ ^ @ ^ @ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ @ @ @ @ @ @ @ ^

# 3. Build and execute XMasTreeApp

The XMasTreeApp application is an application written in Java and allows to produce Xmas tree like the presented in this post.

The source of the XMasTreeApp is available on [3].

## Build

Application has maven structure. You need to use maven in order to build the application.

Execute the following command on the project:

mvn clean install

## Execution

Execute the following command on the built archive:

java -jar com.softexploration.xmas.tree-0.0.1-SNAPSHOT-jar-with-dependencies.jar com.softexploration.xmas.tree.XMasTreeApp

Optionally we can pass number of total rows – the altitude of the triangle + 1 for the star on the top. Default value is 33.

java -jar com.softexploration.xmas.tree-0.0.1-SNAPSHOT-jar-with-dependencies.jar com.softexploration.xmas.tree.XMasTreeApp 10

# References

[1] http://en.wikipedia.org/wiki/Pascal%27s_triangle

[2] http://en.wikipedia.org/wiki/Sierpinski_triangle

[3] https://github.com/softexploration/com.softexploration.xmas.tree