Number Trick

General FreeBASIC programming questions.
angros47
Posts: 1821
Joined: Jun 21, 2005 19:04

Re: Number Trick

Postby angros47 » Aug 28, 2020 18:49

How does it work? Can you show me with 12 x 12, for example?
albert
Posts: 5951
Joined: Sep 28, 2006 2:41
Location: California, USA

Four Step

Postby albert » Aug 28, 2020 20:26

It only works with 90's ( 90 * 10 ) to ( 99 * 99 )

if you multply by 80's , ( 80 x < 90 ) , you need to subtract 200+
if you multply by 70's , ( 70 x < 80 ) , you need to subtract 300+
etc...
if you multply by 10's , ( 10 x < 20 ) , you need to subtract 900+
albert
Posts: 5951
Joined: Sep 28, 2006 2:41
Location: California, USA

Four Step

Postby albert » Aug 28, 2020 20:41

@angros47

It works just like i output back on the last page...

12 x 12 = 144

step 1
subtract
1212 <-- put smaller number besides it's self
-102 <-- one digit under each set
------
1110

step2
subtract
120
-120
------
0

step 3
add
1110
+0
------
1110

===================================================================
since we are multiplying by 10 we need to subtract 900+ ( haven't figured it out yet . )
1110
-900 + ??
------
210 ??
===================================================================

step 4 ( add or subtract )
210
- ??
------
144

I think the sub is 1010 - 0101 = 909 , or 1010 - 0102 = 908 , you migt have to add 12 or a multiple of it , to the 900 val??
1110 - 144 = 966 so the 900 subtraction , is probably ( 966 - less than 24 )
Last edited by albert on Aug 28, 2020 22:28, edited 1 time in total.
albert
Posts: 5951
Joined: Sep 28, 2006 2:41
Location: California, USA

Four Step

Postby albert » Aug 28, 2020 21:31

@angros47

I think i got it figured out... The 900 subtraction ( 100 - 12 ) = 78 = ( 900 + 78 ) = 978

The rule is:
If neither original number ends in 0 then we have to add..
If either original number ends in 0 then we have to subtract..


1110
-978
------
132

step 4
( add or subtract )
132
+12
-----
144

Since neither original number ended in 0 then we know the pre-step 4 value has to be smaller than the actual answer..
Because the rule is , we have to add in that case..

Took me a couple hours to figure out the ( 100 - 12 ) = 78 + the 900

I'm still ironing out the kinks in the concept.. I could use some professional mathematician assistance...
albert
Posts: 5951
Joined: Sep 28, 2006 2:41
Location: California, USA

Five Step

Postby albert » Aug 28, 2020 22:37

@angros47

So 12 x 12 would be:

12 x 12 = 144

step 1
subtract
1212 <-- put smaller number besides it's self
-102 <-- one digit under each set
------
1110

step 2
subtract
120
-120
-------
0

step 3
add
1110
+0
------
0

step 4 ( since we are dealing with a number less than 90 , we need to subtract 1000 - 10 = 900 and add , ( 100 - 12 = 78 ) for a total of 978
subtract
1110
-978
-------
132

step 5
add ( since neither number ended with 0 we add ) else we would subtract...
132
+12
-----
144 <-- correct answer

So now we have "Five Steps" , instead of 4 , if were dealing with 90's we can skip step 4
albert
Posts: 5951
Joined: Sep 28, 2006 2:41
Location: California, USA

Five Step

Postby albert » Aug 28, 2020 22:50

@angros47

With 12 x 12 , was somewhat straight forward...

With 12 x 15 ?? which number would you subtract from 100 ?? the smaller or bigger???

I've still got some wrinkles to iron out....

Since we put the smaller number beside it's self , i would think we need to subtract 100 from the bigger number.. ( 100 - 15 = 85 )
So , in the fourth step , we would subtract 985 in the case of 12 x 15...
angros47
Posts: 1821
Joined: Jun 21, 2005 19:04

Re: Number Trick

Postby angros47 » Aug 28, 2020 23:26

1) if your method needs to be changed case by case, it's not a standard method.
2) the regular method to multiply two 2 digit numbers requires only 3 passages, so your solution is inefficient anyway.
albert
Posts: 5951
Joined: Sep 28, 2006 2:41
Location: California, USA

Re: Number Trick

Postby albert » Aug 28, 2020 23:47

12 x 15 = 180

step 1
subtract
1212
-105
------
1107

step 2
subtract
150
-120
------
30

step 3
add
1107
+30
------
1137

step 4
subtract ( since we are dealing with 1's we need to subtract 900 , ( 900 + ( 100 - 15 = 85 ) = 985 )
1137
-985
------
152

step 5
add or subtract
180 <--- real answer
-152 <-- our result...
------
28 difference ??? how does 12 and 15 make 28 ??? ( 12 + 15 = 27 ) ???
albert
Posts: 5951
Joined: Sep 28, 2006 2:41
Location: California, USA

Re: Number Trick

Postby albert » Aug 28, 2020 23:54

@angros47

The idea is to multply 1,000,000 digits by 1,000,000 digits...

It would only take 4 or 5 steps of additions and subtractions..

I'm working on 2 digits now , taking baby steps...
When i get all the 2 digit values working , I'll move on to 4 x 4 digits..

Maybe i should go down to single digits , and figure out the why's and wherefores , then apply it to 2 digits then up....
albert
Posts: 5951
Joined: Sep 28, 2006 2:41
Location: California, USA

Re: Number Trick

Postby albert » Aug 29, 2020 1:36

@angros47

I'm working on single digits..
I got all the ones and twos working...

The end ( step 5 ) addition , is always plus the bigger number..
When i get done with all the single digits , then I'll go on to 2 digits numbers..

Still ironing out the wrinkles... I'll get it working in a few days or so....

I'm getting close to writing a program , for single digit multiplies..
angros47
Posts: 1821
Joined: Jun 21, 2005 19:04

Re: Number Trick

Postby angros47 » Aug 29, 2020 7:09

For single digit numbers, there is already a simple and effective method, that is usually taught in first grade school: the Pythagorean table.

For number with many digits, you can just use LOG to get the logarithm of both. Add the two logarithms, then use EXP on the result. Try it.
albert
Posts: 5951
Joined: Sep 28, 2006 2:41
Location: California, USA

Five Step

Postby albert » Aug 29, 2020 21:27

I wrote a program for my "Five Step" multiply formula...

Interesting output.... It's close on some numbers.. and off quite a bit on others..

Code: Select all


screen 19

print

do
   
   for a as longint = 1 to 9
       
       print a , 
       
        for b as longint = 1 to 9 step 1
       
            dim as longint v1 = a
            dim as longint v2 = b
           
            if v2 < v1 then swap v1 , v2
           
            'step1  subtract
            dim as longint step1 = ( v1 * 11 ) - v2
           
            'step2  subtract
            dim as longint step2 = v2 - v1
           
            'step 3 add
            dim as longint step3 = step1 + step2
           
            'step 4 subtract
            dim as longint step4 = step3 - ( 10 - v2 - v1 )
           
            'step 5 add
            dim as longint step5 = step4 - v1
           
            dim as string ans = right( "000" + str( step5 ) , 3 )
           
            print  ; ans ; " " ;
           
        next
       
        print
   
    next

    sleep
   
loop until inkey = chr( 27 )

sleep
end

angros47
Posts: 1821
Joined: Jun 21, 2005 19:04

Re: Five Step

Postby angros47 » Aug 30, 2020 13:33

albert wrote:Interesting output.... It's close on some numbers.. and off quite a bit on others..


Then the formula is wrong. In math, either a formula always works, or it is wrong. Also, your formula is much more complicated than the standard formula, so what is the point?
albert
Posts: 5951
Joined: Sep 28, 2006 2:41
Location: California, USA

Find Next Square

Postby albert » Aug 30, 2020 19:56

I found a way of finding the next square...

1 = 01
2 = 04
3 = 09
4 = 16
5 = 25
6 = 36
7 = 49
8 = 64
9 = 81

If you know the square of 4 = 16 .. You can find the square of 5 , by adding 4 + 5 ( 16 + ( 4 + 5 ) = 25 )
If you know the square of 6 = 36 .. You can find the square of 7 , by adding 6 + 7 ( 36 + ( 6 + 7 ) = 49 )

It also works in reverse...

If you know the square of 6 = 36 .. You can find the square of 5 , by adding 6 + 5 ( 36 - ( 6 + 5 ) = 25 )
If you know the square of 9 = 81 .. You can find the square of 8 , by adding 9 + 8 ( 81 - ( 9 + 8 ) = 64 )

Could be useful for finding the next higher or lower square of a "BigNumber"

If you know the square of 222 = 49,284 then you can find the square of 223 by adding 49,284 + ( 222 + 223 ) = 49,729
Last edited by albert on Aug 30, 2020 20:13, edited 1 time in total.
angros47
Posts: 1821
Joined: Jun 21, 2005 19:04

Re: Number Trick

Postby angros47 » Aug 30, 2020 20:13


Return to “General”

Who is online

Users browsing this forum: No registered users and 11 guests