Author Topic: Digisibility Test (Z80 ASM)  (Read 1587 times)

0 Members and 1 Guest are viewing this topic.

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Digisibility Test (Z80 ASM)
« on: April 02, 2013, 01:03:50 pm »
Inspired by Round 2 of the 2013 TI-Concours BASIC category, I made this assembly program to test if a number is digisible. A number is digisible if every digit of the number divides the whole number evenly. Since you cannot divide by 0, every number with a 0 in it is automatically not digisible. So the input is a positive integer, and the output is text drawn to the screen where 0 =  not digisible, 1=digisible.

So here is what I was wondering: How fast or small can you make a program like this in assembly? My version takes a string input, so long as it fits in RAM and properly outputs a result. It is also 140 bytes on the calculator, so I am thinking it could be made a bit smaller XD (I think it is 122 bytes of code).

Hopefully I will remember to convert the code to readable source code, later. My approach is to keep track of which digits are in the sequence while finding the value of the string mod 2520 (every digit 1~9 divides 2520). Then, check to see if each present digit divides that value. At the same time, if any value appears that is not 1~9, it returns 0, so this takes care of non-integers and integers with a 0 in their digit expansion.

Offline Dapianokid

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 539
  • Rating: +46/-27
  • That one dude
    • View Profile
Re: Digisibility Test (Z80 ASM)
« Reply #1 on: April 02, 2013, 04:52:25 pm »
Is there a program to find the palindrome of a number?
I love writing BASIC programs for things like this or for other functions :)
Keep trying.