Weird Function

DescriptionIn data science, quite often you need to implement research papers and write code according to what's present in those papers. Research papers have a lot of maths involved and you need to implement the maths in code. In this exercise, you're required to implement some maths in code. The problem is as follows:

For fixed integers a, b, c, define a weird function F(n) as follows:
F(n) = n - c for all n > b
F(n) = F(a + F(a + F(a + F(a + n)))) for all n ≤ b.

Also, define S(a, b, c) = ∑F(n) where n takes the values 0 till b [in other words, S(a, b, c) = F(0) + F(1) + F(2) + .... F(b-1) + F(b)].

The input will be the value of a, b and c. The output should be S(a, b, c). You can define the functions in your own customized way with no restrictions on the number of parameters. For example, you can define the function S which can take additional parameters than a, b and c. Just make sure the code behaves as per the maths.

For example, if a = 20, b = 100 and c = 15, then F(0) = 195 and F(2000) = 1985.
Therefore, S(20, 100, 15) = 14245

Input:
3 values separated by a comma
a,b,c

Output:
S(a,b,c)

Sample input:
20, 100, 15

Sample output:
14245 Jun 22, 2020 in Python 1,643 views

Hi, @Rocking,

Do you write a full code regarding your query?

## 1 answer to this question.

input_str = input()
input_list = input_str.split(',')

a = int(input_list)
b = int(input_list)
c = int(input_list)

# write code here

sum = 0

def weird_function(a,b,c,n):
#base case
if n>b:
return n-c
#action and recursive calls
#here more than one recurssive calls will be needed
else:

def large_sum(a, b, c):
large_sum = 0
for value in range(b+1):
large_sum += weird_function(a, b, c, value)
return large_sum

result = large_sum(a, b, c)

print(result) answered Jul 28, 2020 by Vin

## Using generator function in Python

A generator is effectively a function that ...READ MORE

## How to print objects of class using print function in Python?

>>> class Test: ... ...READ MORE

## I am using a built-in function name as a method identifier and sometimes as an attribute in Python, is this bad?

Hi, good question. The thing is that ...READ MORE

## How to make a laplacian pyramid using OpenCV python?

down voteacceptTheeThe problem is that you're iterating ...READ MORE

## How can I play an audio file in the background using Python?

down voteacceptedFor windows: you could use  winsound.SND_ASYNC to play them ...READ MORE

## how can i randomly select items from a list?

You can also use the random library's ...READ MORE

+1 vote

## how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE