Python初識 實現識別x~y之間得數爲質數還是合數

版權聲明:本文爲博主原創文章,未經博主允許不得轉載。 https://blog.csdn.net/Q718330882/article/details/80046258
nums = (int(input( '請輸入第一個數字:' )),int(input( '請輸入第二個數字:' )))
for n in range(x,y+1):
	for i in range( 2, n-1):
		if n % i == 0:
			print( '%d 是合數' % n )
			break
		else:
			print( '%d 是質數' % n )


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章