ش | ی | د | س | چ | پ | ج |
1 | 2 | 3 | 4 | 5 | 6 | |
7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 | 29 | 30 |
به زبان پایتون، برنامهای بنویسید که دو عدد طبیعی را دریافت کند و اعداد اول بین آنها را در اختیار کاربر قرار دهد. در صورتی که حداقل یکی از دو عدد، عددی صحیح کوچکتر از 1 باشد یا دو عدد برابر باشند، خروج از برنامه رخ دهد.
Write a program in Python which receives two natural numbers as input and provides all the prime numbers in the interval between them. If either of the input numbers is an integer less than 1 or the two numbers are equal, exit the program.
For i in range(2,51)
For n in range(2,i)
If i%n==0
Break
Else: print (i)
>>> a=range(10,100,1)
>>> [i for i in a if ( i%2 and i%3 and i%5 and i%7)]
[11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]