Toggle menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Self-describingSequence/shon: Difference between revisions

From ZeroWiki
imported>Unknown
No edit summary
 
(Repair batch-0003 pages from live compare)
 
Line 1: Line 1:
== Source - 1차 ==
== Source - 1차 ==
  function idx = selfd(N)
  function idx = selfd(N)
  seq =[[1 2 2] zeros(1,500000)];
  seq =[[1 2 2] zeros(1,500000)];
  idx = 4;
  idx = 4;
  acc = 5;
  acc = 5;
Line 22: Line 22:
  i = 2;
  i = 2;
  b = 2;
  b = 2;
  seq =[[1 3] zeros(1,500000)];
  seq =[[1 3] zeros(1,500000)];
   
   
  while seq(I)<n
  while seq(I)<n
Line 31: Line 31:
     seq(I) = seq(i-1) + b;
     seq(I) = seq(i-1) + b;
  end
  end

Latest revision as of 00:29, 27 March 2026

Source - 1차

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차

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