from uturtle import *

def triangle(t, n, size):
    if n == 0:
        moveForward(t, size)
        turnLeft(t, 120)
        moveForward(t, size)
        turnLeft(t, 120)
        moveForward(t, size)
        turnLeft(t, 120)
    else:
        triangle(t, n-1, size/2)
        moveForward(t, size/2)
        triangle(t, n-1, size/2)
        moveBackward(t, size/2)
        turnLeft(t, 60)
        moveForward(t, size/2)
        turnRight(t, 60)
        triangle(t, n-1, size/2)
        turnLeft(t, 60)
        moveBackward(t, size/2)
        turnRight(t, 60)

if __name__ == "__main__":
    t= umonsTurtle()
    moveBackward(t, 250)
    triangle(t, 5, 500)
    wait()
