[phpBB Debug] PHP Warning: in file [ROOT]/phpbb/db/driver/mysqli.php on line 264: mysqli_fetch_assoc(): Couldn't fetch mysqli_result
[phpBB Debug] PHP Warning: in file [ROOT]/phpbb/db/driver/mysqli.php on line 326: mysqli_free_result(): Couldn't fetch mysqli_result
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4149: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3027)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4149: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3027)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4149: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3027)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4149: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3027)
Pete's QBASIC Site • Multiplication simple
Page 1 of 1

Multiplication simple

Posted: Fri Jan 15, 2010 8:21 am
by lrcvs
'Program multiplication simple
'lrcvs
'(MU) Spain
'13 Jan 2010

'This program is based on: a * b = c >>> a = c / b

CLS

a$ = "9876543298789"
b$ = "2468013"

la = LEN(a$) + LEN(b$)
c$ = STRING$(la, "0")

FOR r = 1 TO la
FOR s = 0 TO 9
MID$(c$, r) = LTRIM$(STR$(s))
v$ = LTRIM$(STR$(VAL(c$) / VAL(b$)))
IF v$ = a$ THEN PRINT "Prog = "; VAL(c$): PRINT : PRINT "Comp = "; VAL(a$) * VAL(b$): END
IF VAL(a$) > VAL(v$) THEN MID$(c$, r) = LTRIM$(STR$(s))
IF VAL(a$) < VAL(v$) THEN MID$(c$, r) = LTRIM$(STR$(s - 1)): EXIT FOR
NEXT s
NEXT r
SLEEP
END