Perhaps you should tell us what you did to define multiplication.
Do you understand that division is the inverse of multiplication?
Ok I know the title makes it sound easy but that’s not the point.
The problem I’ve got is actually computer related but with a maths twist. I have a very basic programming language which has only the Add and Subtract functions, I've made a working multiply function but it only deals with whole numbers as does the whole program.
So anyway is there a method of dividing using only add and subtract and whole number multiplication. I don't know if this is making any sense it started playing with my head so sorry. But if anyone can help that would be great.
Martin
indeed. we can actually think of division as a weird form of subtraction, or more appropriately, counting a certain number of subtractions. for example: 12 divided by 2 is 6. why? because we can subtract 2 from 12 6 times.
if your program can do "loops" this shouldn't be too hard for you to code. (note, i am not in the least adept at programming, but i've heard people talk about algorithms before, so i'll describe an algorithm to you).
Algorithm for calculating
Let counter = 0 and remainder = 0
if b = 0
..........print: is undefined
else
..........if a < b
....................print:
(and you can program it to output in decimal if you want, so if a = b you will get 1)
.........else
...................while a > b, do:
...........................remainder = a - b
...........................counter = counter + 1
...........................a = remainder
...................end while loop
...................print: counter " and " remainder/b
.........end if
end if
so basically this algorithm counts the number of times you can subtract b from a, and also keeps track of the remainder when doing so. as long as the remainder is greater than zero and a is greater than b, it will keep subtracting and keep counting. in the end, the result will be the number of counts we have plus the remainder over the dividend. (at least that's what the program is supposed to do. you figure out the details, like i said, i'm not a programmer)
indeed, but how would you code something like that? i can visualize an algorithm using subtraction in my head, but i'm a little confused as to how to tell a computer to do the inverse of multiplication
o wait, i got an idea just now while typing this, i'll think about it some more.
Just as you did above: if we add to multiply then subtract to divide.
But note that he/she did say that these are whole numbers, no decimals.
So while multiplication has no restrictions, division does have restrictions.
I wanted to see what code he/she had. I think there is some shorter code using while and until.