Question 15

Write a function which returns the number of times the digit “1” appears in a number which is generated from raising 11 to the Nth power where N is passed in as an input parameter. The range of N is 0 to 1,000.

Be sure to unit test your solution.

For instance, If N is 3, the number is 1331 and the function returns 2.

If N is 5, the function returns 3.

If N is 10, the function returns 1 and so on.

public int solution(int N) { … }

[advanced_iframe securitykey=”undefined” src=”https://code.kodnest.com/” width=”100%” height=”600″]

KodNest Training New Batch is starting on 02nd November 2020. Attend one week free demo classes.Register Now

New Report

Close