Computer Science, asked by theRockstar3653, 11 months ago

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 rakeshchennupati143
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:

  1. in first line of code i took value only in int by using int() method which is predefined in python
  2. in 2nd line of code i printed value of (n-1) directly
  3. 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