dmath: init directory

This commit is contained in:
Jeremy Baxter 2024-02-16 09:29:09 +13:00
parent afa80b0937
commit 84bf83a36b
7 changed files with 200 additions and 0 deletions

48
dmath/README.md Normal file
View file

@ -0,0 +1,48 @@
D programs that calculate various mathematical values
## factors.d - calculate the factors of a number
To work out the factors of 31:
ldc2 -run factors.d 31
## isfactor.d - determine whether a number is a factor of another
To determine whether 8 is a factor of 32:
ldc2 -run isfactor.d 8 32
## hcf.d - calculate the highest common factor of two numbers
To work out the HCF of 12 and 28:
ldc2 -run hcf.d 12 28
To keep it simple this program will write out a list of factors
for each number side-by-side.
## lcm.d - calculate the lowest common multiple of two numbers
To work out the LCM of 28 and 42:
ldc2 -run lcm.d 28 42
To keep it simple this program will write out a list of multiples
for each number side-by-side.
## primes.d - generate a list of prime numbers up to a maximum value
To generate a list of primes up to 100:
ldc2 -run primes.d
If an argument is supplied, the program will calculate primes up to that number:
ldc2 -run primes.d 10
(outputs 2, 3, 5, and 7)
Two arguments can be supplied to specify a minimum as well:
ldc2 -run primes.d 1 20
(outputs primes from 1 to 20)