Menu
Question Index
...

Write a program to get the numbers which are perfect powers of the given number.

Input (int[], int) Output (int[])
{2, 5, 9, 16, 36, 50, 64, 85, 100, 128, 144}, 2 {2, 16, 64, 128}
{1, 3, 7, 9, 15, 20, 27, 55, 81, 100}, 3 {1, 3, 9, 27, 81}
{2, 5, 20, 25, 155, 625, 100, 125}, 5 {5, 25, 625, 125}
{1, 10, 50, 100, 200, 500, 1000}, 10 {1, 10, 100, 1000}



class FindPerfectPowersOfGivenNumber
{
    public static void main(String s[])
    {
        int inputArray[] = {5, 10, 15, 25, 30, 50, 100, 125};
        int number = 5;
        int output[] = getPerfectPowers(inputArray, number);
        System.out.println("Numbers which are perfect powers of " + number + " are : ");
        for (int result : output)
        System.out.print(result + ", ");

    }


    public static int[] getPerfectPowers(int array[], int number) {
    }

}

Doubts

Problems

Topic: For-each Loop In Core Java Programming

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App