2016年8月23日 星期二

python 程式設計50題測試範例-11


11、阿婆賣蛋,七個一數餘二,九個一數餘二,三個一數餘二,求<10000之

      內的所有可能結果。

11.
輸出範例一
2,  65, 128, 191, 254, 317, 380, 443, 506, 569, 632, 695, 758, 821, 884, 947,
1010,1073,1136,1199,1262,1325,1388,1451,1514,1577,1640,1703,1766,1829,1892,1955,
2018,2081,2144,2207,2270,2333,2396,2459,2522,2585,2648,2711,2774,2837,2900,2963,
3026,3089,3152,3215,3278,3341,3404,3467,3530,3593,3656,3719,3782,3845,3908,3971,
4034,4097,4160,4223,4286,4349,4412,4475,4538,4601,4664,4727,4790,4853,4916,4979,
5042,5105,5168,5231,5294,5357,5420,5483,5546,5609,5672,5735,5798,5861,5924,5987,
6050,6113,6176,6239,6302,6365,6428,6491,6554,6617,6680,6743,6806,6869,6932,6995,
7058,7121,7184,7247,7310,7373,7436,7499,7562,7625,7688,7751,7814,7877,7940,8003,
8066,8129,8192,8255,8318,8381,8444,8507,8570,8633,8696,8759,8822,8885,8948,9011,
9074,9137,9200,9263,9326,9389,9452,9515,9578,9641,9704,9767,9830,9893,9956,

程式:
#coding:Big5

#11、阿婆賣蛋,七個一數餘二,九個一數餘二,三個一數餘二,求<10000之
#      內的所有可能結果。

print(" =========python 程式設計50題測試範例-11==================")
print("11、阿婆賣蛋,七個壹數餘二,九個壹數餘二,三個壹數餘二,")
print("      求<10000之內的所有可能結果。")
print()

print("阿婆賣蛋~~太有趣了!結果有:")

for i in range(1,10000):
        if (i%7==2 and i%9==2 and i%3==2) :
                print('{:d}'.format(i),end=",")
                

結果: 
================= RESTART: D:/程式語言 Python 入門/50題/Ex50-11.py =================
 =========python 程式設計50題測試範例-11==================
11、阿婆賣蛋,七個一數餘二,九個一數餘二,三個一數餘二,
      求<10000之內的所有可能結果。

阿婆賣蛋~~太有趣了!結果有:
2,65,128,191,254,317,380,443,506,569,632,695,758,821,884,947,1010,1073,1136,1199,1262,1325,1388,1451,1514,1577,1640,1703,1766,1829,1892,1955,2018,2081,2144,2207,2270,2333,2396,2459,2522,2585,2648,2711,2774,2837,2900,2963,3026,3089,3152,3215,3278,3341,3404,3467,3530,3593,3656,3719,3782,3845,3908,3971,4034,4097,4160,4223,4286,4349,4412,4475,4538,4601,4664,4727,4790,4853,4916,4979,5042,5105,5168,5231,5294,5357,5420,5483,5546,5609,5672,5735,5798,5861,5924,5987,6050,6113,6176,6239,6302,6365,6428,6491,6554,6617,6680,6743,6806,6869,6932,6995,7058,7121,7184,7247,7310,7373,7436,7499,7562,7625,7688,7751,7814,7877,7940,8003,8066,8129,8192,8255,8318,8381,8444,8507,8570,8633,8696,8759,8822,8885,8948,9011,9074,9137,9200,9263,9326,9389,9452,9515,9578,9641,9704,9767,9830,9893,9956,
>>> 


沒有留言:

張貼留言

Messaging API作為替代方案

  LINE超好用功能要沒了!LINE Notify明年3月底終止服務,有什麼替代方案? LINE Notify將於2025年3月31日結束服務,官方建議改用Messaging API作為替代方案。 //CHANNEL_ACCESS_TOKEN = 'Messaging ...