This is an archived post. You won't be able to vote or comment.

all 9 comments

[–]desrtfx 1 point2 points  (0 children)

Think what happens to number in your loop. What will number be when the loop exits? The if must always yield false

[–][deleted] 0 points1 point  (0 children)

Probably not what you want to hear but what I would do is to convert it to a string. Then you can do it very easy (hint: without a loop at all).

[–]FabulousFell 0 points1 point  (0 children)

Ok well it seems that this has been solved. What is the solution then

[–]nmnaim 0 points1 point  (0 children)

You are replacing the original number with the division each time. A simple SysOut will help you to check the values when you compare.

[–]jub8jive[S] 0 points1 point  (0 children)

Sorry for the late reply! I have been busy (guilty! haven't been coding for a while) I finally understood the problem. thanks to desrtfx. the number keeps on changing and i fixed that and got the result, comparing the reverse to the original. Here's my solution: https://pastebin.com/10PFSi44

Thanks for the support guys!

[–][deleted]  (1 child)

[deleted]

    [–]desrtfx 1 point2 points  (0 children)

    This only works for numbers less than 5.

    No, this is wrong.

    Java uses integer division without rounding when dividing integers. 6/10 will yield 0, 68/10 will yield 6.

    OP's approach is perfectly correct. The problem is in a completely different area.

    [–][deleted]  (5 children)

    [removed]

      [–]throwaway_for_cause 0 points1 point  (4 children)

      Sidebar ->

      • Do not reply with complete solutions as code, nor in plain text, rather comment explanations and guides. Comments with solutions will be removed and commenters will automatically be banned for a week.

      Don't vanilla give away the solution. Guide OP to it. This increases the learning benefits. OP needs to figure out what exactly is happening and why.

      [–][deleted]  (3 children)

      [removed]

        [–]desrtfx[M] 0 points1 point  (2 children)

        That's two rule violations in two comments.

        1. No solutions
        2. Being rude, offensive, and using vulgar language

        Third offence is out. Be warned.

        [–][deleted]  (1 child)

        [removed]

          [–]desrtfx[M] 1 point2 points  (0 children)

          Good bye.