Share your repls and programming experiences

← Back to all posts
Multiply #WEEKLY Usage of math module

Using the math module, I managed to use an equation to multiply two numbers. I used the `pow` (to the tenth) function and `log10`, creating a lambda function here:
`math.pow(10, (math.log10(a) + math.log10(b)))`
I can't wait to see what other solutions people come up with!

PowerCoder (623)

Almost 100% accurate. Look here:

Codemonkey51 (884)

No external libraries :)

AmazingMech2418 (938)

@Codemonkey51 I think math is a standard library in Python though (kind of like stdlib in C or iomanip in C++).

AmazingMech2418 (938)

@Codemonkey51 But math isn't external. It is natively in Python, although not automatically in the program. (nearly) Every language has a default sqrt function, for example, and that is in the math module in Python. Also, it would be unfair for someone to not be able to do this in Python, but use the Math object in JS and get away with it since it doesn't use external libraries/modules.

Codemonkey51 (884)

Idk leave that up to the judges @AmazingMech2418

AmazingMech2418 (938)

@Codemonkey51 Though, what I mean is that I can do the exact same method in Node without a library, so it shouldn't be restricted by languages. By that logic, you could never do anything for this in C, C++, C#, and maybe even like Java!

AgastyaSandhuja (163)

I bet \$5 ur gonna win
ur the one person who did something else

PYer (3503)

Thanks! I was going to do something like @CodingCactus, but then I saw everyone was doing the simple solutions. @AgastyaSandhuja

PYer (3503)

thanks! glad you like it! @CodingCactus

CodingCactus (3086)

awwwwwwww, it doesn't work with 0 as the second number :(

AmazingMech2418 (938)

@CodingCactus `log(0) = undefined`

PYer (3503)

okay, i'll try and fix it @CodingCactus

AmazingMech2418 (938)

Nice use of logarithms! I thought about doing this, but decided to go with strings instead...

eartharoid (0)

10*2 = 20.000000000000004
perfect

ChezCoder (1548)

@PYer also, I recommend you round the result because its giving very long decimals :D

PYer (3503)

Thanks, I'll try that, and I don't know about your post. everything is left to the judges. @ChezCoder