# Python program to find the solution of a special sum series

Here, we are going to learn how to find the solution of a given special sum series in Python?
Submitted by Anuj Singh, on August 08, 2019

We are going to design a special sum series function which has following characteristics:

```    f(0) = 0
f(1) = 1
f(2) = 1
f(3) = 0
f(x) = f(x-1) + f(x-3)```

Python solution of the above sum series

```# function to find the sum of the series
def summ(x):
if x == 0:
return 0
if x == 1:
return 1
if x == 2:
return 1
if x == 3:
return 0

else:
return summ(x-1) + summ(x-4)

# main code
if __name__ == '__main__':
# finding the sum of the series till given value of x
print("summ(0) :", summ(0))
print("summ(1) :", summ(1))
print("summ(2) :", summ(2))
print("summ(3) :", summ(3))
print("summ(10):", summ(10))
print("summ(14):", summ(14))
```

Output

```summ(0) : 0
summ(1) : 1
summ(2) : 1
summ(3) : 0
summ(10): 5
summ(14): 17
```

TOP Interview Coding Problems/Challenges

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates