-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path152.py
More file actions
33 lines (24 loc) · 698 Bytes
/
152.py
File metadata and controls
33 lines (24 loc) · 698 Bytes
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
# https://www.freecodecamp.org/learn/daily-coding-challenge/2026-01-09
def is_circular_prime(n):
numbers = list(str(n))
for i in range(len(numbers)):
# Rotate digits.
first = numbers.pop(0)
numbers.append(first)
# Get integer number.
string = ""
for j in numbers:
string += j
number = int(string)
# Check if prime.
if not is_prime(number):
return False
return True
# Copied from https://www.w3schools.com/java/java_howto_check_prime_num.asp
def is_prime(n):
i = 2
while i * i <= n:
if n % i == 0:
return False
i += 1
return True