.. blogpost::
:title: Exam, doubts and poetry
:keywords: exam, EratoshÃ¨ne
:date: 2016-03-03
:categories: examen
This is one question we decided to remove from the final exam
but I still do like it because it challenges people.
How to make a connection between known algorithms
and the following code. To your opinion, the following
code is closed to:
* `Djiksta's algorithm `_
* `Eratosthenes `_
* `Binary search algorithm `_
::
import math
def meslogs_jusque(N):
memolog = { 1:0.0 }
for i in range(2,N+1):
if i in memolog:
pass
else:
l = math.log(i)
total = i
for j in range(total, N+1, total):
memolog[j] = memolog.get(j, 0.0) + l
total *= i
while total < N+1:
for j in range(total, N+1, total):
memolog[j] += l
total *= i
return memolog