-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathday-9(hw).py
More file actions
70 lines (27 loc) · 1.08 KB
/
day-9(hw).py
File metadata and controls
70 lines (27 loc) · 1.08 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/env python
# coding: utf-8
# In[39]:
get_ipython().run_cell_magic('writefile', 'samp_le.pylintrc', 'def is_prime(number):\n """\n Return True if *number* is prime.\n """\n for element in range(number):\n if number % element == 0:\n return False\n return True\n\ndef print_next_prime(number):\n """\n Print the closest prime number larger than *number*.\n """\n index = number\n while True:\n index += 1\n if is_prime(index):\n print(index)')
# In[40]:
get_ipython().system(' pylint "samp_le.pylintrc"')
# # assignment 2
# In[16]:
# Program to check Armstrong numbers in a certain interval
lower = int(input("Enter lower range: "))
upper = int(input("Enter upper range: "))
for num in range(lower,upper + 1):
# initialize sum
sum = 0
# find the sum of the cube of each digit
temp = num
while temp > 0:
digit = temp % 10
sum += digit ** 3
temp //= 10
if num == sum:
print(num)
# In[ ]:
# In[ ]:
# In[ ]:
# In[ ]:
# In[ ]: