Source - 1차 ¶
~cpp function idx = selfd(N) seq =[[1 2 2] zeros(1,500000)]; idx = 4; acc = 5; x = 3; while 1 for i = 1 : seq(X) seq(idx) = x; acc = acc + x; if acc >= n return end idx = idx + 1; end x = x + 1; end
Source - 2차 ¶
~cpp function i = selfdscribing(N) i = 2; b = 2; seq =[[1 3] zeros(1,500000)]; while seq(I)<n i = i + 1; if seq(B) < i b = b + 1; end seq(I) = seq(i-1) + b; end