myfibonacci-easy-contest

Many of you know the famous Fibonacci sequence F:
F[1] = 1
F[2] = 1
F[i] = F[i - 1] + F[i - 2] for i > 2

Thus each number in sequence is a sum of two previous numbers except two first which are define as 1.

You've decided to create you own Fibonacci sequence. It's very similar to the one described above, but the first two numbers now are arbitrary non-negative integers A and B ( F[1] = A and F[2] = B ). Now you want to compute the N-th number in your sequence.

Input
The only line contains 3 space-separated integers A, B, N.

Output
Output one integer - the N-th number in your sequence.

Constraints
0 < A, B, N ≤ 10

SAMPLE INPUT
1 3 4

SAMPLE OUTPUT
7

Difficulty: EASY
Tags: Mathematics

Starter code:

Solutions:
a,b,n = list(map(int,input().split()))

if n == 1:
	print(a)
elif n == 2:
	print(b)
else:
	fib = a+b
	a = b
	b = fib
	n = n-2
	while n>1:
		fib =(a+b)
		a = b
		b = fib
		n -=1
	print(fib)


a,b,n= list(map(int,input().split()))
fib=[]
fib.append(a)
fib.append(b)
for i in range(2,15):
	fib.append(fib[i-1]+fib[i-2])
print(fib[n-1])


def mod_fib(L):
	if(L[2]<2):
		 return L[L[2]-1]
	else:
		for i in range(L[2]-2):
			t=L[0]+L[1]
			L[0]=L[1]
			L[1]=t
	return L[1]

L=list(map(int,input().split()))
print(mod_fib(L))


A,B,N = list(map(int, input().split()))
if N == 1:
	F = A
elif N == 2:
	F = B
else:
	while( N-2 > 0):	
		F = A + B
		A = B
		B = F
		N -= 1
print(F)
	


a,b,n = list(map(int,input().split()))
lis = list();
lis.append(a)
lis.append(b)
for i in range(2,n):
	lis.append(lis[i - 1] + lis[i - 2])
print(lis[n-1])


a,b,n = list(map(int,input().split()))

if n==1:
	print(a)
elif n==2:
	print(b)
else:
	i=2
	while i<n:
		c=a+b
		a=b
		b=c
		i+=1
	print(c)


a,b,c = [int(x) for x in input().split()]
l = [a,b]
for i in range(2,c):
	d = a + b
	l.append(d);
	a = b
	b = d

print((l[c-1]))
	
	


def fib(a,b,n):
	if n==1:
		return a
	elif n==2:
		return b
	else:
		for _ in range(n-2):
			c=b
			b=a+b
			a=c
			
	return b

a,b,n=list(map(int, input().split()))
print(fib(a,b,n))
		


ip = input().split(' ');
a = int(ip[0])
b = int(ip[1])
n = int(ip[2])
ans = a if n==1 else b if n==2 else 0
for i in range(3, n+1):
	ans = a + b;
	a = b;
	b = ans
print(ans)
	


a,b,n=list(map(int,input().split()))
x=2
f=[a,b]
for i in range(2,n):
	f.append(f[i-1]+f[i-2])
print(f[n-1])


'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
a,b,n = list(map(int, input().split()))
l = [a, b]
for i in range(n):
	l.append(l[-1]+l[-2])
print(l[n-1])



numbers = input().split()
n1 = int(numbers[0])
n2 = int(numbers[1])
n = int(numbers[2])

if n == 1:
	print(n1)
elif n == 2:
	print(n2)
else:
	for i in range(3, n + 1):
		nextTerm = n1 + n2
		n1 = n2
		n2 = nextTerm
	print(nextTerm)


#!/usr/bin/env python
#-*- coding:utf-8 -*-

import sys, math, random, operator
from string import ascii_lowercase
from string import ascii_uppercase
from fractions import Fraction, gcd
from decimal import Decimal, getcontext
from itertools import product, permutations, combinations
from queue import Queue, PriorityQueue
from collections import deque, defaultdict, Counter
getcontext().prec = 100

MOD = 10**9 + 7
INF = float("+inf")

if sys.subversion[0] != "CPython":  # PyPy?
	raw_input = lambda: sys.stdin.readline().rstrip()
pr = lambda *args: sys.stdout.write(" ".join(str(x) for x in args) + "\n")
epr = lambda *args: sys.stderr.write(" ".join(str(x) for x in args) + "\n")
die = lambda *args: pr(*args) ^ exit(0)

read_str = raw_input
read_strs = lambda: input().split()
read_int = lambda: int(input())
read_ints = lambda: list(map(int, input().split()))
read_float = lambda: float(input())
read_floats = lambda: list(map(float, input().split()))

"---------------------------------------------------------------"


a, b, n = read_ints()

if n == 1:
	print(a)
elif n == 2:
	print(b)
else:
	while n > 2:
		n -= 1
		a, b = b, a + b
	print(b)


'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
#print 'Hello World!'
a,b,n=input().split(" ")
a,b,n=int(a),int(b),int(n)
if n==1:
	print(a)
elif n==2:
	print(b)
else:
	for i in range(2,n):
		f=a+b
		a=b
		b=f
	print(f)


'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
a,b,n = list(map(int,input().split()))
def nth_term(a,b,n):
	if(n==1):
		return a
	elif(n==2):
		return b
	else:
		return nth_term(a+b,b+a+b,n-2)

print(nth_term(a,b,n))


a, b, n = list(map(int, input().split()))
arr = [a, b]
for _ in range(2, n):
	arr.append(arr[-1] + arr[-2])
print(arr[n - 1])


A, B, N = list(map(int, input().split()))

if N == 1:
	print(A)
elif N == 2:
	print(B)
else:
	for i in range(N - 2):
		A, B = B, A + B
	print(B)


def fib(A, B, N):
	if N == 1:
		return A
	if N == 2:
		return B
	C = A + B
	for i in range(4,N+1):
		B, C = C, B + C
	return C

A, B, N = list(map(int, input().split()))
print(fib(A, B, N))


'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
def fibb ():
	a, b, n = list(map (int, input ().split ()))
	x = a
	y = b 
	for i in range (3,n+1):
	
		ans = x + y
		x = y
		y = ans
	
	if n == 1:
		print(x)
	elif n == 2:
		print(y)
	else:
		print(ans)

if __name__ == "__main__":
	fibb()