I have a problem to solve which takes as input a number n. The problem has a property that given the solution for (n-1), i can easily solve the problem for n. Which programming technique will i use to solve such a problem?
Answers
Answered by
0
Answer:
print("solution for (n-1) is ",( n-1 ) ) { code is in python }
Program in python:
n = int ( input ( "Enter a number" ) )
print("solution for (n-1) is ",( n-1 ) )
Explanation:
- in first line of code i took value only in int by using int() method which is predefined in python
- in 2nd line of code i printed value of (n-1) directly
- so you can print the value that has to be calculated dirctly in the print statement weather it is java or c or c++ or python or any other programming language that has output statements
----Hope you liked my answer mark brainliest if you liked my answer ......and if you have any doubts regarding programming or coding feel free to approach me :)
Similar questions