forked from perfecto25/math_stuff
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdoubler.py
60 lines (37 loc) · 927 Bytes
/
doubler.py
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
def moveLastToFirst(num):
string = str(num)
mylist = list(string)
# for position, item in enumerate(mylist):
# print "position: %s, item: %s" % (position, item)
last = mylist[-1]
length = len(mylist)
mylist.insert(0,last)
last = mylist[-1]
length = len(mylist)
del mylist[length-1]
mylist = ''.join(mylist)
num = int(mylist)
return num
def compare(num):
double = num * 2
ltf = moveLastToFirst(num)
# print "ltf %s" % ltf
#if num == 2000:
# return "found"
if ltf == double:
return "found"
i = 1
while True:
print i
returnval = compare(i)
if returnval is "found":
print "FOUND"
file = "answer.txt"
content = open(file, 'r+')
print "i is %s" % i
var = str(i)
content.write(var)
content.close()
break
else:
i = i + 1