Skip to content

Primitive calculator using iterative dynamic programming approach

License

Notifications You must be signed in to change notification settings

rymshasaeed/primitive-calculator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Primitive Calculator

A primitive calculator has been programmed that can perform the following three operations with the current number X:

  • subtract 1 from X
  • divide X by 2
  • divide X by 3

Given a positive integer n, the calculator determines the minimum number of operations needed to obtain 1 starting from the number n.

Samples

Please enter a number: 25
n = 25
Number of operations = 5
Sequence of operations: [1 2 2 2 3]
Please enter a number: 394
n = 394
Number of operations = 10
Sequence of operations: [2 1 2 2 1 2 2 2 2 3]
Please enter a number: 6
n = 6
Number of operations = 2
Sequence of operations: [2 3]
Please enter a number: 9999
n = 9999
Number of operations = 16
Sequence of operations: [3 3 1 2 3 1 2 2 2 1 2 1 2 1 2 2]

About

Primitive calculator using iterative dynamic programming approach

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages