算法练习--打印Cantor 数表

var n=1;
var m=1;
var i = 1;
var flag="m";

for(var index = 1;index<12345;index++){

flag = i%2 == 0 ? "n" : "m";

if(flag == "n"){if(n==i){n++;m=1;i++;}else{n++;m--;}}
else {if(m == i){m++;n=1;i++;}else{m++;n--;}}

}

console.log(n+"/"+m);

你可能感兴趣的:(ant)