Algo 100 - Appended Fibonacci Sum

Writer: Jakob Degen
Flag: 726786993

This problem can be solved quickly using a brute force approach. The following code will find the complete sum of the as described in the problem.

sum = 0 # This is the total sum

for current in range(1, 51):
  toAdd = 1
  lastFib = 1
  secondLastFib = 0

  for fib in range(2, current + 1): # Because current + 1 is excluded
    next = lastFib + secondLastFib

    toAdd = int(str(toAdd) + str(next)) # Appends toAdd with next

    secondLastFib = lastFib
    lastFib = next

  sum = sum + toAdd

print(sum)

This will output the following number: 11235813213568249574479570837509514492304324461080130708376818975123606249142995262906961942242089015346626285852302491331133211853430264531618889335083976553558833441748283085210519467865518396933757372600162819660375528506552246628148550963137112296039845694864583313056018

The final nine digits of this number are 313056018, the flag.

results matching ""

    No results matching ""