Argument to Methods



Example Programs



Program [1]

A positive whole number ‘n’ that has ‘d’ number of digits is squared and split into two pieces, a right-hand piece that has ‘d’ digits and a left-hand piece that has remaining ‘d’ or ‘d-1’ digits. If the sum of the two pieces is equal to the number, then ‘n’ is a Kaprekar number. The first few Kaprekar numbers are: 9, 45, 297 ……..


Example 1:


9

92 = 81, right-hand piece of 81 = 1 and left hand piece of 81 = 8 Sum = 1 + 8 = 9, i.e. equal to the number.


Example 2:


45

452 = 2025, right-hand piece of 2025 = 25 and left hand piece of 2025 = 20 Sum = 25 + 20 = 45, i.e. equal to the number.


Example 3:


297

2972 = 88209, right-hand piece of 88209 = 209 and left hand piece of 88209 = 88 Sum = 209 + 88 = 297, i.e. equal to the number.


Given the two positive integers p and q, where p < q, write a program to determine how many Kaprekar numbers are there in the range between p and q (both inclusive) and output them.


The input contains two positive integers p and q. Assume p < 5000 and q < 5000. You are to output the number of Kaprekar numbers in the specified range along with their values in the format specified below:


SAMPLE DATA:


INPUT:

p = 1

q = 1000 OUTPUT:

THE KAPREKAR NUMBERS ARE:- 1, 9, 45, 55, 99, 297, 703, 999

FREQUENCY OF KAPREKAR NUMBERS IS: 8



View Solution

CCC Online Test 2021 CCC Practice Test Hindi Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Best Java Training Institute in Prayagraj (Allahabad) Best Python Training Institute in Prayagraj (Allahabad) O Level NIELIT Study material and Quiz Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Sarkari Naukari Notification Best Website and Software Company in Allahabad Website development Company in Allahabad