$n=%v$

$ 圖解\sum_{k=1}^{n}{ k^2} $

A = (0.73758, 1.56844)
n = 1 (slider from 1 to 5, step 1)
list1 = Sequence(Sequence[A + (j, k), j, 0, (n * (n + 1)) / 2], k, 0, n)
list2 = Sequence(Segment[A + (j, 0), A + (j, n)], j, 0, (n * (n + 1)) / 2)
list3 = Sequence(Segment[A + (0, j), A + ((n * (n + 1)) / 2, j)], j, 0, n)
poly1, a, b, c, d = Polygon(A, A + (1, 0), A + (1, 1), A + (0, 1))
poly2, e, f, g, h = Polygon(A + (1, 0), A + (3, 0), A + (3, 2), A + (1, 2))
poly3, i, j, k, l = Polygon(A + (3, 0), A + (6, 0), A + (6, 3), A + (3, 3))
poly4, m, p, q, r = Polygon(A + (6, 0), A + (10, 0), A + (10, 4), A + (6, 4))
poly5, s, t, a_1, b_1 = Polygon(A + (10, 0), A + (15, 0), A + (15, 5), A + (10, 5))
list5 = Sequence(Polygon[A + (j(j - 1) / 2, 0), A + (j(j + 1) / 2, 0), A + (j(j + 1) / 2, j), A + (j(j - 1) / 2, j)], j, 1, n)
text5: "$ " + (LaTeX[If[n ≟ 5, "1+2+3+4"]]) + " $"
text4: "$ " + (LaTeX[If[n ≥ 4, "1+2+3"]]) + " $"
text3: "$ " + (LaTeX[If[n ≥ 2, "1+2"]]) + " $"
text2: "$ " + (LaTeX[If[n ≥ 2, "1"]]) + "$"
polyA, c_1, d_1, e_1, f_1 = Polygon(A + (0, 1), A + (1, 1), A + (1, 2), A + (0, 2))
polyB, g_1, h_1, i_1, j_1 = Polygon(A + (0, 2), A + (3, 2), A + (3, 3), A + (0, 3))
polyC, k_1, l_1, m_1, n_1 = Polygon(A + (0, 3), A + (6, 3), A + (6, 4), A + (0, 4))
polyD, p_1, q_1, r_1, s_1 = Polygon(A + (0, 4), A + (10, 4), A + (10, 5), A + (0, 5))
text1: "$  " + (LaTeX[n]) + "×" + (LaTeX[If[n ≟ 1, "1", If[n ≟ 2, "(1+2)", If[n ≟ 3, "(1+2+3)", If[n ≟ 4, "(1+2+3+4)", If[n ≟ 5, "(1+2+3+4+5)"]]]]]]) + "=\sum_{k=1}^{" + (LaTeX[n]) + "}{ k^2}" + (LaTeX[If[n ≟ 1, "", If[n ≟ 2, "+1", If[n ≟ 3, "+1+(1+2)", If[n ≟ 4, "+1+(1+2)+(1+2+3)", If[n ≟ 5, "+1+(1+2)+(1+2+3)+(1+2+3+4)"]]]]]]) + "$"
text7: "$⇒\sum_{k=1}^{" + (LaTeX[n]) + "}{ k^2}=" + (LaTeX[n]) + " ×" + (LaTeX[(n * (n + 1)) / 2]) + "" + (LaTeX[If[n ≥ 2, "-1"]]) + "" + (LaTeX[If[n ≥ 3, "-3"]]) + "" + (LaTeX[If[n ≥ 4, "-6"]]) + "" + (LaTeX[If[n ≟ 5, "-10"]]) + "=" + (LaTeX[n * (n + 1) * (2 * n + 1) / 6]) + "$"