New to programming

>new to programming
>took me 1 hr to intuitively grasp this(get result of number to the xth power)

Attached: exponent.png (776x368, 9.27K)

probably would be easier to read if the retard used N++ or something. Using "Long" for everything is confusing when it isn't color-specified as a data type.
I don't blame you OP. There's a lot of ways to learn how to program and pajeets always find the dumbest methods.

well learning is a process, you can't just download and install complete knowledge and understanding of a concept

The fractional portion of the exponent parameter is ignored, so this code contains a bug.

I struggle wit iterations, like Im the type of guy to be conffused when u say "see me in 5 days" and Im like 5 days including this day or from next day so 6 days kek

But these things take it to a whole new level like in OP pic its like a delay of 2 until you reach >1 and my mind struggles to grasp it

proud of u anony, programming is frustrating but its rly fun. keep at it

>old to programming
>never have to do anything like that
In the real world you just use what is already available.

This is why the best programmers start when they are young. All programmers struggle with shit like this at the start.

Should have used a while loop. Not sure why you did it this way ngl.

There's also no way to stop a negative input, which isn't handled using this method.

Keep at it user, it'll be a struggle since you're starting "later" than everyone else but I'm sure you can do it!

Attached: 1653144114233.jpg (682x1000, 458.02K)

Negatives can be elevated

Attached: IMG-20220520-WA0006.jpg (396x339, 26.64K)

>fractional portion of the exponent parameter
it's a long tho

Yeah. If you want to ignore the fractional part on purpose, it should be an int.

long is just an int with more bits, you're thinking of a double

what said
floating point exponentiation is a much harder problem

Doubles are just ints with more bits too
You can use those extra bits you know

this doesn't even work if exponent=0, also why tf is it long

Attached: aLwkkExJ_700w_0.jpg (263x276, 12.53K)

>fractional portion of the exponent
Take your meds. The nth power of x is just x multiplied with itself n times. Can't do that with fractional n.

Negative exponent results in an infinite loop. Even if it didn't, the calculation would be inversed. Like user says, he's also using a long for the exponent but the calculation method solves for only interfere.

Only for integer

>Doubles are just ints with more bits too
but the argument was passed in as a long. if you cast the long into a double and then perform floating point math then you're just creating a really shitty api

x^(1/m) = mth root of x
eg x^(3/2) = (x^3)^(1/2) = sqrt(x^3)

Imagine needing color coding to understand a three line method. We can break out the crayons for you Dylan. It's against the law not to accommodate autism.

To be fair, that should be caught outside it since that's the only appropriate place to handle it.

for loops are unironically much harder to understand than while loops
t. avoided for loops for months when i started programming

how do you feel about making the argument type unsigned to force the programmer to acknowledge it

Lol

They are not difficult to understand at all. OP shouldn't worry though, because most people are retarded and find programming difficult even though it's easier than basic math so if he can program at all he's a cut above the rest.

for a complete beginner while loops make sense because it's just one step per line
for loops put 3 steps in 1 line which is confusing

Anything under five years experience is a complete beginner

There's a power method in the static class "Math". I think it's called either pow or exp. Been a while since I programmed in Java. I hope you know the difference between static and non-static atm, as it is very very helpful. Object orientation and memory management (memory leaks) are the topics I'd recommend to really try to grasp. Everything after is a cake walk. Java has implicit memory leaks (eg, you forget to remove an "unused" object from a list and the garbage collector doesn't collect it). I might also suggest picking up a copy of Effective Java. iirc that's the name of a helpful book. Don't listen to jackoffs, you're doing great!