The solution is #y=c_0 cosx+c_1 sinx#.
Let us look at some details.
Let #y=sum_{n=0}^inftyc_nx^n#, where #c_n# is to be determined.
By taking derivatives,
#y'=sum_{n=1}^inftync_nx^{n-1} Rightarrow y''=sum_{n=2}^inftyn(n-1)c_nx^{n-2}#
We can rewrite #y''+y=0# as
#sum_{n=2}^inftyn(n-1)c_nx^{n-2}+sum_{n=0}^inftyc_nx^n=0#
by shifting the indices of the first summation by 2,
#Rightarrow sum_{n=0}^infty(n+2)(n+1)c_{n+2}x^n+sum_{n=0}^inftyc_nx^n=0#
by combining the summations,
#Rightarrow sum_{n=0}^infty[(n+2)(n+1)c_{n+2}+c_n]x^n=0#,
#Rightarrow (n+2)(n+1)c_{n+2}+c_n=0#
#Rightarrow c_{n+2}=-{c_n}/{(n+2)(n+1)}#
Let us look at even coefficients.
#c_2={-c_0}/{2cdot1}=-c_0/{2!}#
#c_4={-c_2}/{4cdot3}={-1}/{4cdot3}cdot{-c_0}/{2!}=c_0/{4!}#
#c_6={-c_4}/{6cdot5}={-1}/{6cdot5}cdot c_0/{4!}=-{c_0}/{6!}#
.
.
.
#c_{2n}=(-1)^n{c_0}/{(2n)!}#
Let us look at odd coefficients.
#c_3={-c_1}/{3cdot2}=-{c_1}/{3!}#
#c_5={-c_3}/{5cdot4}={-1}/{5cdot4}cdot{-c_1}/{3!}={c_1}/{5!}#
#c_7={-c_5}/{7cdot6}={-1}/{7cdot6}cdot{c_1}/{5!}=-{c_1}/{7!}#
.
.
.
#c_{2n+1}=(-1)^n{c_1}/{(2n+1)!}#
Hence, the solution can be written as:
#y=sum_{n=0}^inftyc_nx^n#
by splitting into even terms and odd terms,
#=sum_{n=0}^inftyc_{2n}x^{2n}+sum_{n=0}^inftyc_{2n+1}x^{2n+1}#
by pluggin in the formulas for #c_{2n}# and #c_{2n+1}# we found above,
#=c_0sum_{n=0}^infty(-1)^n{x^{2n}}/{(2n)!}+c_1 sum_{n=0}^infty(-1)^n{x^{2n+1}}/{(2n+1)!}#
by recognizing the power series,
#=c_0 cosx+c_1 sinx#