Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Any math experts know what I'm missing here? [Solved]
#12
@Jack

I did read that yesterday. That plus this https://en.wikipedia.org/wiki/Nth_root#Examples on Wikipedia helped me make this, which I think works... [NOTE: I haven't put a decimal place in yet, just digits.]

Code: (Select All)
$CONSOLE:ONLY
DIM AS DOUBLE d, i, j, r, t, x, oldx
INPUT "Whole number: "; n%
INPUT "Root: "; r%
r = r%
n$ = LTRIM$(STR$(n%))
h&& = (r - (r - LEN(n$) MOD r)) + 1
t = VAL(MID$(n$, 1, h&& - 1))
limit&& = 8
DO
    lcnt&& = lcnt&& + 1
    PRINT "Target ="; t
    FOR j = 1 TO 10
        x = 0
        FOR i = 1 TO r
            IF i = 1 THEN
                PRINT "(10 ^"; (i - 1); "*"; i; "* d ^"; i - 1; " * j ^"; (r + 1 - i); ") + ";
                x = x + 10 ^ (i - 1) * i * d ^ (i - 1) * j ^ (r + 1 - i)
            ELSE
                PRINT "(10 ^"; (i - 1); "*"; r; "* d ^"; i - 1; " * j ^"; (r + 1 - i); ") + ";
                x = x + 10 ^ (i - 1) * r * d ^ (i - 1) * j ^ (r + 1 - i)
            END IF
        NEXT
        PRINT "<<<"; x
        IF x > t THEN EXIT FOR
        oldx = x
    NEXT
    d = VAL(LTRIM$(STR$(d)) + LTRIM$(STR$(j - 1)))
    PRINT "t - oldx as: "; t; "-"; oldx; "="; t - oldx,: COLOR 14: PRINT "d ="; d: COLOR 7
    tmp1$ = LTRIM$(STR$(t - oldx))
    tmp2$ = MID$(n$, h&&, r) + STRING$(r - LEN(MID$(n$, h&&, r)), "0")
    PRINT "tmp1$ = "; tmp1$, "tmp2$ = "; tmp2$, "n$ = "; n$
    t = VAL(tmp1$ + tmp2$) ' This will remove any leading zeros carried down.
    h&& = h&& + r
    IF t = 0 AND h&& >= LEN(n$) OR lcnt&& = limit&& THEN EXIT DO
LOOP
PRINT
RUN

Pete
Shoot first and shoot people who ask questions, later.
Reply


Messages In This Thread
RE: Any math experts know what I missing here? - by Pete - 09-23-2022, 07:40 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  _putimage (Solved) Pete 0 224 11-16-2025, 06:48 AM
Last Post: Pete
  random maze map. math help pmackay 4 572 08-10-2025, 11:22 AM
Last Post: pmackay
Tongue Ubuntu 18.0.4 C++ Compilation Failed SOLVED (sorta) Shed_Grill 6 885 07-14-2025, 12:32 AM
Last Post: Shed_Grill
  After using the font, the IDE is ripe for reinstallation SOLVED! Petr 8 1,411 12-12-2024, 04:45 PM
Last Post: Petr
  [Solved] How come CLS clears more than the _DEST image here? Dav 2 770 10-07-2024, 12:14 AM
Last Post: Dav

Forum Jump:


Users browsing this thread: 1 Guest(s)