Home  /  Questions  /  Question



50   50
Apr 23, 2015


Series of Add/Subtract/Multiply

Hi , 

            i am building a function , where i get an amount , i need to go to series of seven steps (only 7 not dynamic). Each of this step will do Step1 - add, Step2- Multiply , Step3 - Subtract  .... till Step 7 . The compute operation is also earlier known

Can i use some pattern for this problem?

e.g   ; Input 5000

Step 1 : 5000 + 1000 = 6000

Step 2: 6000 * 2 = 12000

Step 3 12000 - 10000 = 2000

-
-
Step 7 - Final Output

Thanks
Thomson



50   50
Apr 28, 2015
You may use Interpreter pattern.

Thanks,
Sandeep Mittal