Giter Site home page Giter Site logo

rymshasaeed / primitive-calculator Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 8 KB

Primitive calculator using iterative dynamic programming approach

License: Apache License 2.0

MATLAB 100.00%
dynamic-programming matlab optimal-substructure primitive-calculator

primitive-calculator's Introduction

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]

primitive-calculator's People

Contributors

rymshasaeed avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.