All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars    
perplexus dot info

Home > Just Math
Casting Out Zeros (Posted on 2013-07-25) Difficulty: 4 of 5
One may perform the following two operations on a natural number:

1.Multiply it by any natural number
2.Delete zeros in its decimal representation.

For any natural number n, can one perform a sequence of these operations that will transform n to a one-digit number?

No Solution Yet Submitted by Danish Ahmed Khan    
No Rating

Comments: ( Back to comment list | You must be logged in to post comments.)
Some Thoughts re: good for 11 thru 999 Comment 4 of 4 |
(In reply to good for 11 thru 999 by Charlie)

There are too many lines to list all 999 series, but they all did work. These are based on:

DECLARE SUB try (n#, lv#)
DECLARE FUNCTION nozero$ (n#)
DEFDBL A-Z
OPEN "casting out zeros.txt" FOR OUTPUT AS #2
DIM SHARED hMult(15), hProd(15), hNozero$(15), didit
n0 = 1
FOR n0 = 11 TO 999
    IF n0 = 0 THEN END
    n = n0
    didit = 0
    IF INSTR(STR$(n), "0") = 0 THEN
        PRINT n0
        PRINT #2, n0
        try n, 1
        IF didit = 0 THEN PRINT "-----------": PRINT #2, "------------"
    END IF
NEXT
FUNCTION nozero$ (n)
s$ = ""
ns$ = LTRIM$(STR$(n))
FOR i = 1 TO LEN(ns$)
    IF MID$(ns$, i, 1) > "0" THEN s$ = s$ + MID$(ns$, i, 1)
NEXT
nozero$ = s$
END FUNCTION
SUB try (n, lv)
FOR mult = 2 TO 99
    IF didit THEN EXIT SUB
    prod = mult * n
    nz$ = nozero$(prod)
    IF INSTR(STR$(prod), "0") > 0 AND mult MOD 10 <> 0 THEN
        good = 1
        FOR i = 1 TO lv - 1
            IF hNozero$(i) = nz$ THEN good = 0: EXIT FOR
        NEXT
        IF good THEN
            hNozero$(lv) = nz$
            hProd(lv) = prod
            hMult(lv) = mult
            IF LEN(nz$) < 2 THEN
                FOR i = 1 TO lv
                    PRINT i, hMult(i), hProd(i), hNozero$(i)
                    PRINT #2, i, hMult(i), hProd(i), hNozero$(i)
                NEXT
                didit = 1
                EXIT FOR
            ELSE
                IF lv < 6 THEN
                    try VAL(nz$), lv + 1
                END IF
            END IF
        END IF
    END IF
NEXT mult
END SUB

BTW, to complete the 2-digit numbers, for 99:

 99 
 1             11            1089         189
 2             9             1701         171
 3             6             1026         126
 4             4             504          54
 5             2             108          18
 6             5             90           9

 


  Posted by Charlie on 2013-07-26 13:09:00
Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (0)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (3)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2017 by Animus Pactum Consulting. All rights reserved. Privacy Information