U E D R , A S I H C RSS

Self-describing Sequence/shon

No older revisions available

No older revisions available



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
Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:28:00
Processing time 0.0155 sec