Find Reverse of Integer

package org.wesome.dsalgo;

public class IntegerReverse {
    static int integer = 0;

    public static int integerReverse(int no) {
        while (no != 0) {
            integer = integer * 10 + (no % 10);
            return integerReverse(no / 10);
        }
        return integer;
    }
}
package org.wesome.dsalgo;

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

import static org.wesome.dsalgo.IntegerReverse.integerReverse;

public class IntegerReverseTest {
    @Test
    void integerReverseTest() {
        int integer = 12345;
        int finalSum = integerReverse(integer);
        Assertions.assertEquals(54321, finalSum);
    }
}
plugins {
    id 'java'
}

group = 'org.wesome'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = JavaVersion.VERSION_1_8

repositories {
    mavenCentral()
}
dependencies {
    testImplementation('org.junit.jupiter:junit-jupiter:5.6.2')
}

test {
    useJUnitPlatform()
}

 

follow us on