Your code doesn't run for us because these variables are not defined:
D=D39+D40+DO+DNa+DFe; %coefficienti di diffusione
F=F39+F40; %prodotti di fissione
CAPTURE=[Pu39capture+Pu40capture+Nacapture+Fecapture+Ocapture]; %sigma di cattura
FISSION=[Pu39fission+Pu40fission]; %sigma di fissione
ELREM=[Pu39elrem+Pu40elrem+Naelrem+Feelrem+Oelrem]; %sigma di scattering elastico(direclty coupled)
but in general you should ALWAYS have a failsafe like "&& n < nMax" to prevent infinite loops.
If it doesn't exit until n hits nMax then there is some other problem with your exit condition abs(K-1)>(10^-5). It must always be true so evidently your K never gets in the range 0.99999 to 1.00001.