Giter Club home page Giter Club logo

196-algorithm's Introduction

196-algorithm

Implementation of the 196-algorithm to find palindromes in an iteratively computed number sequence.

Inspired by https://www.youtube.com/watch?v=bN8PE3eljdA&t=374s

Execution

git clone https://github.com/NumericalMax/196-algorithm.git
cd 196-algorithm
g++ main.cpp -o main
./main

Approach

Given a number n we iteratively reassign to n the sum of n and the reverse of n until n is a palindrome.

Example Given:

n = 19 // no palindrome, iteration = 0
n = 19 + 91 = 110 // no palindrome, iteration = 1
n = 110 + 11 = 121 // palindrome, iteration = 2

Note, that n is of type int. This can result in exceeding the allocated storage size for larger n or higher iterations. To prevent, you can set the datatype to long or a much larger datatype.

Outcome

Number Iterations Final palindrome
1 0 1
2 0 2
3 0 3
4 0 4
5 0 5
6 0 6
7 0 7
8 0 8
9 0 9
10 1 11
11 0 11
12 1 33
13 1 44
14 1 55
15 1 66
16 1 77
17 1 88
18 1 99
19 2 121
20 1 22

196-algorithm's People

Contributors

numericalmax avatar

Watchers

 avatar  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.