Program which create vertical pyramid with recursion
public class MainClassVisualRecursionV {
public static void main(String[] args) {
recursion(5, "", "\\", "/");
}
public static int recursion(int deep, String space, String symbol, String flipSymbol)
{
System.out.println(space + symbol);
if(deep < 0)
{
System.out.println(space + flipSymbol);
}
else
{
recursion(deep - 1, space + " ", symbol, flipSymbol);
System.out.println(space + flipSymbol);
}
return deep;
}
}
Output:
\
\
\
\
\
\
\
/
/
/
/
/
/
/