How to resolve the algorithm Palindromic gapful numbers step by step in the J programming language

Published on 12 May 2024 09:40 PM
#J

How to resolve the algorithm Palindromic gapful numbers step by step in the J programming language

Table of Contents

Problem Statement

Numbers   (positive integers expressed in base ten)   that are (evenly) divisible by the number formed by the first and last digit are known as   gapful numbers.

Evenly divisible   means divisible with   no   remainder.

All   one─   and two─digit   numbers have this property and are trivially excluded.   Only numbers   ≥ 100   will be considered for this Rosetta Code task.

1037   is a   gapful   number because it is evenly divisible by the number   17   which is formed by the first and last decimal digits of   1037.

A palindromic number is   (for this task, a positive integer expressed in base ten),   when the number is reversed,   is the same as the original number.

For other ways of expressing the (above) requirements, see the   discussion   page.

All palindromic gapful numbers are divisible by eleven.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Palindromic gapful numbers step by step in the J programming language

Source code in the j programming language

palindromify=: [: , ((,~ |.@}.) ; (,~ |.))&>
gapful=: (0 = (|~ ({.,{:)&.(10&#.inv)))&>
task2_cartesian_products=: [: , [: { ((i. 10) ; (>: i. 9)) #~ ,&1
task2_palindromes=: [: 10&#.&> [: palindromify task2_cartesian_products
task2_gapfuls=: [: /:~ [: ; [: (#~ gapful)@task2_palindromes&.> >:@i.


  

You may also check:How to resolve the algorithm Singly-linked list/Element definition step by step in the Phix programming language
You may also check:How to resolve the algorithm Roman numerals/Decode step by step in the MATLAB programming language
You may also check:How to resolve the algorithm Associative array/Iteration step by step in the Sidef programming language
You may also check:How to resolve the algorithm Reflection/Get source step by step in the Nim programming language
You may also check:How to resolve the algorithm Egyptian division step by step in the R programming language