Posts

Showing posts from April, 2025

Lychrel number

Image
  Lychrel number # programming # mathematics # algorithms # numbertheory A Lychrel number is a natural number that cannot form a palindrome through the iterative process of reversing its digits and adding the resulting numbers. This process is often referred to as the  196-algorithm , named after the most famous number associated with it. To determine if a number is a Lychrel number in Pascal, we implement a string-based approach to handle large numbers generated during iterations. Here's a structured solution: Key Components String Reversal: Reverse the digits of a number represented as a string. String Addition: Add two large numbers (as strings) to avoid integer overflow. Palindrome Check: Verify if a string is a palindrome. Iteration Loop: Perform up to 500 iterations of reversal and addition, checking for palindromes. Pascal Implementation var Seeds : array of LongInt ; function ReverseString ( s : string ): string ; var i : integer ; begin Result := '...

Multi Pascal Solver🐞

Image
  Skip to content Welcome to maXbox  Code (Blog) maXbox maXbox   About   Contact   Blog   Code Multi Pascal Solver Posted on  April 3, 2025  by  maxbox4 A  sphenic number  is a positive integer that is the product of three distinct prime numbers. More technically it’s a square-free 3-almost prime (see Related tasks below). For the purposes of this task, a  sphenic triplet  is a group of three sphenic numbers which are consecutive. I want to show the solution from rosettacode in five language variants: Pascal Python Free Pascal Free Pascal TIO Web Delphi Note that sphenic quadruplets are not possible because every fourth consecutive positive integer is divisible by 4 (= 2 x 2) and its prime factors would not therefore be distinct. Example 30 (= 2 x 3 x 5) is a sphenic number  and is also clearly the first one. Lets start with Object Pascal in maXbox5 Editor: Result in maXbox Console 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ...