Skip to content

Commit 0f78cd6

Browse files
author
Thejus-Paul
committed
Project Euler Solution Added
1 parent 3fae059 commit 0f78cd6

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

Diff for: Project Euler/Problem 14/sol1.py

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
largest_number = 0
2+
pre_counter = 0
3+
4+
for input1 in range(750000,1000000):
5+
counter = 1
6+
number = input1
7+
8+
while number > 1:
9+
if number % 2 == 0:
10+
number /=2
11+
counter += 1
12+
else:
13+
number = (3*number)+1
14+
counter += 1
15+
16+
if counter > pre_counter:
17+
largest_number = input1
18+
pre_counter = counter
19+
20+
print('Largest Number:',largest_number,'->',pre_counter,'digits')

Diff for: Project Euler/README.md

+7
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,10 @@ PROBLEMS:
4242
a^2 + b^2 = c^2
4343
There exists exactly one Pythagorean triplet for which a + b + c = 1000.
4444
Find the product abc.
45+
46+
14. The following iterative sequence is defined for the set of positive integers:
47+
n → n/2 (n is even)
48+
n → 3n + 1 (n is odd)
49+
Using the rule above and starting with 13, we generate the following sequence:
50+
13 → 40 → 20 → 10 → 5 → 16 → 8 → 4 → 2 → 1
51+
Which starting number, under one million, produces the longest chain?

0 commit comments

Comments
 (0)