How to resolve the algorithm Self-describing numbers step by step in the PARI/GP programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Self-describing numbers step by step in the PARI/GP programming language

Table of Contents

Problem Statement

There are several so-called "self-describing" or "self-descriptive" integers. An integer is said to be "self-describing" if it has the property that, when digit positions are labeled 0 to N-1, the digit in each position is equal to the number of times that that digit appears in the number. For example,   2020   is a four-digit self describing number:

Self-describing numbers < 100.000.000  are:     1210,   2020,   21200,   3211000,   42101000.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Self-describing numbers step by step in the PARI/GP programming language

Source code in the pari/gp programming language

S=[1210, 2020, 21200, 3211000, 42101000, 521001000, 6210001000];
isself(n)=vecsearch(S,n)

  

You may also check:How to resolve the algorithm Minesweeper game step by step in the MATLAB programming language
You may also check:How to resolve the algorithm Statistics/Normal distribution step by step in the PureBasic programming language
You may also check:How to resolve the algorithm Pascal's triangle step by step in the IDL programming language
You may also check:How to resolve the algorithm Go Fish step by step in the D programming language
You may also check:How to resolve the algorithm Currying step by step in the Logtalk programming language