P3

อยากได้ตัวเลขที่หารด้วย 3 ลงตัวจากตัวเลข 999-1 พิมพ์ออกทางหน้าจอครับ 🙂

for i in range(1000,1, -1):
 if 0 == i % 3:
   print i , 
#print '\n---------'
print '\n'+'-'*10
# re-initial i
i = 999 
while i > 0:
 if 0 == i % 3:
   print i , 
 i -= 1
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s