1. Java version, recursive.
package shawn.test;
public class Thousand {
public static void main(String[] args) {
descrease2(1000);
}
public static Integer descrease2(Integer i) {
try{
Integer tmp = 1 / (i+1);
}catch(Exception e){
System.exit(1);
}
System.out.println(i--);
descrease2(i);
return i;
}
}
2. Javascript Version, implementing Javascript Closure
<script type="text/javascript">
function test($num) {
document.write($num+"<br />");
$num--;
return $num>0?test($num):document.write("0<br />");
}
var testMe = test(1000);
testMe();
</script>
3. Perl version, using language buildin looping feature.
#!/usr/local/bin/perl -w
@array = (0 .. 1000);
map {print $_, "\t"} @array;
> or
#!/usr/local/bin/perl -w
@array = (0 .. 1000);
grep {print $_, "\t"} @array;
> Extreme version, only 19 charactrors, no white space,
> no quotes, no brackets, no semicolon:
map{print$_}0..1000
订阅:
博文评论 (Atom)
没有评论:
发表评论