Linux Bash/Shell:
[root@mem shell]# cat prime.sh #!/bin/sh# Print prime from 1 to 100for ((i=1;i<=100;i++))do if [ $i -eq 1 ];then continue fi flag=0 for ((j=2;j
Python写法(2.6.6):
Python写法1[root@mem python]# cat prime.py #!/usr/bin/python#Print prime 1-100for i in range(1,100): if i == 1: continue for j in range(2,i): if i % j == 0: break else: print i, 'is a prime'Python写法2[root@mem python]# cat while_break.py #!/usr/bin/pythoni = 2while i < 100: j = 2 while j <= (i/j): if not(i%j): break j += 1 else: print i, 'is prime' i += 1