[[練習問題]]

 # -*- coding: utf-8 -*-
 def preme_check(x):
   if x<2:
     return 0
   if x==2 :
     return 1
   if x%2==0:
     return 0
 
   a=3
   while a**2 <= x:
     if x%a==0:
       return 0
     a=a+2
 
   return 1
 
 x=input ('値を入力してください')
 if preme_check(x)==1:
   print '素数です'
 if preme_check(x)==0:
   print '素数ではありません'
 exit()


トップ   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS