Create an array containing the numbers till the given input number - Java Quiz Question


Write a program to create an array containing all the numbers till a given input number.

Input (Integer) Output (Integer Array)
5 {1, 2, 3, 4, 5}
3 {1, 2, 3}



class CreateNumbersArrayTillGivenInput
{
    public static void main(String s[])
    {
        int result[] = createNumbersArrayTillGivenInput(6);
        
        for(int i = 0; i < result.length; i++)
        {
            System.out.println(result[i]);
        }

    }


    public static int[] createNumbersArrayTillGivenInput(int input)
    {
    }

}