Programming Challenges for Beginners
Programming Challenges for Beginners
Tina is an enthusiastic stargazer who loves to watch the night sky from her terrace. She
recently bought a telescope to count stars in a specific segment of the sky. To record her
observations, she wants to write down the number of each star she sees, starting from 1, then
2, and continuing until she reaches N stars. This way she can maintain a detailed logbook of
her stargazing journey and later compare it with her previous notes. Your task is to help her
generate this sequence of numbers for her diary.
Input Format:
One line: Integer N
Output Format:
N lines, each with a number from 1 to N
Constraints:
1 ≤ N ≤ 100
Sample Input:
5
Sample Output:
1
2
3
4
5
Problem 2: Festival Lights
In Vikram’s hometown, the annual festival of lights is celebrated with great enthusiasm. The
houses are decorated with lamps at even-numbered positions along the main road, while odd-
numbered spots are kept for flower decorations. Vikram is in charge of checking all the lamp
positions, but he only needs to verify the even-numbered spots. To make his job easier, you
must list all even numbers from 1 to N, representing the positions of the lamps. This way,
Vikram can quickly inspect whether all lights are properly placed.
Input Format:
One line: Integer N
Output Format:
Even numbers from 1 to N
Constraints:
1 ≤ N ≤ 100
Sample Input:
10
Sample Output:
2
4
6
8
10
Problem 3: Village Harvest Tracker
Anil lives in a farming village where every family records their daily wheat harvest. On day 1,
Anil harvested 1 sack of wheat, on day 2 he harvested 2 sacks, and the pattern continues
increasing by 1 sack every day. At the end of N days, Anil wants to calculate the total harvest
so that he can report it to the village committee. Your job is to help him add up the daily
harvest for the first N days.
Input Format:
One line: Integer N
Output Format:
Sum:
Constraints:
1 ≤ N ≤ 1000
Sample Input:
5
Sample Output:
Sum: 15
Problem 4: Quiz Challenge
Meena is preparing for her school’s annual mathematics quiz competition. One of the
questions requires calculating the factorial of a number, which means multiplying all numbers
from N down to 1. Since she cannot use calculators during the quiz, she must practice
calculating factorials by hand or with the help of programming. Write a program that will allow
her to enter a number N and get the factorial instantly, helping her get faster for the real
competition.
Input Format:
One line: Integer N
Output Format:
Factorial:
Constraints:
0 ≤ N ≤ 12
Sample Input:
5
Sample Output:
Factorial: 120
Problem 5: Market Stall Price Board
Arya runs a vegetable stall in her local market and wants to help her customers quickly
calculate bulk prices. She sells tomatoes at a base price per kilogram and wants to create a
board that shows the cost from 1 kg up to 10 kg. Instead of calculating each price separately,
she wants a program to automatically print the multiplication table of the base price. This way,
customers can check the chart and instantly know the cost of buying in bulk.
Input Format:
One line: Integer N (base price)
Output Format:
10 lines showing N x weight = total price
Constraints:
1 ≤ N ≤ 100
Sample Input:
5
Sample Output:
5x1=5
5 x 2 = 10
...
5 x 10 = 50
Problem 6: Rocket Countdown
Kabir volunteers at the science exhibition where a small model rocket is being launched. To
build excitement among the audience, he is given the task of announcing the countdown. If
the countdown starts from N seconds, Kabir must announce each number in reverse until 1.
After the countdown reaches 1, the rocket will take off. Write a program to help Kabir prepare
for this role so he can practice with any starting number.
Input Format:
One line: Integer N
Output Format:
Numbers from N down to 1
Constraints:
1 ≤ N ≤ 100
Sample Input:
5
Sample Output:
5
4
3
2
1
Problem 7: Postal Code Checker
Ravi works at a busy post office where he needs to verify packages before dispatch. Each
package has a postal code printed on it, and for special verification, Ravi is asked to calculate
the sum of the digits in the code. Since the codes can be long and sometimes confusing, Ravi
needs a quick way to calculate the digit sum. Write a program that takes the postal code and
provides the sum of its digits instantly.
Input Format:
One line: Integer N
Output Format:
Sum of digits:
Constraints:
0 ≤ N ≤ 10^6
Sample Input:
123
Sample Output:
Sum of digits: 6
Problem 8: Banner Printing
Sita works at a printing shop where she has to design banners for school functions and events.
For one of the designs, she has been asked to print a line of stars. The exact number of stars
required is given by N, and they must all appear in a single line without spaces. This will form
the base design for the banner. Write a program to generate the correct sequence of stars.
Input Format:
One line: Integer N
Output Format:
One line of N stars
Constraints:
1 ≤ N ≤ 100
Sample Input:
5
Sample Output:
Problem 9: Voltage Amplifier
Raghav is studying electronics and has built a small amplifier for his project. The amplifier’s
output depends on two values: base (a) and exponent (b). The output is calculated as a raised
to the power b. Since he is learning programming too, his professor challenges him to calculate
this value using loops instead of built-in functions. Write a program to help Raghav test his
amplifier’s power output for different values of a and b.
Input Format:
Two lines: base a and exponent b
Output Format:
Result:
Constraints:
0 ≤ a ≤ 100, 0 ≤ b ≤ 10
Sample Input:
2
3
Sample Output:
Result: 8
Problem 10: Security Passcode
Pooja is setting up a digital lock system for her new home. To make it more secure and fun,
she decides to allow only palindrome numbers as passcodes. A palindrome number reads the
same forward and backward. For example, 121 is valid but 123 is not. When a visitor enters a
passcode, the system must check whether it qualifies. Write a program to verify if a given
number is a palindrome or not.
Input Format:
One line: Integer N
Output Format:
Palindrome or Not Palindrome
Constraints:
0 ≤ N ≤ 10^5
Sample Input 1:
121
Sample Output 1:
Palindrome
Sample Input 2:
123
Sample Output 2:
Not Palindrome
Problem 11: Odd Basket Collection
Ramesh works in a large fruit orchard where baskets are neatly arranged in a row and
numbered from 1 to N. Each basket has fruits, but only the odd-numbered ones are meant for
his family. The even-numbered baskets are reserved for the market. To avoid mistakes, he
wants a simple list of all odd-numbered baskets up to N so that he knows exactly which ones
to pick fruits from. Write a program that generates this list for Ramesh.
Input Format:
One line: Integer N
Output Format:
Odd numbers from 1 to N
Constraints:
1 ≤ N ≤ 100
Sample Input:
10
Sample Output:
1
3
5
7
9
Problem 12: Magic Range Sum
Priya is fascinated by numbers divisible by 3. Her teacher tells her to calculate the sum of all
such numbers up to N. She imagines these numbers as magical steps that lead to treasure in
a board game. To find out how many treasures she can unlock, Priya wants to add them all
together. Write a program that computes the sum of numbers divisible by 3 from 1 to N.
Input Format:
One line: Integer N
Output Format:
Sum:
Constraints:
1 ≤ N ≤ 1000
Sample Input:
10
Sample Output:
Sum: 18
Problem 13: Factor Counter
Ajay enjoys solving math riddles. He is currently stuck on one where he has to find out how
many factors a number has. For example, the number 12 has factors like 1, 2, 3, 4, 6, and 12.
Ajay wonders how to calculate such counts quickly without manually listing them. Write a
program to count the total number of factors of N so Ajay can continue solving riddles
efficiently.
Input Format:
One line: Integer N
Output Format:
Count:
Constraints:
1 ≤ N ≤ 1000
Sample Input:
12
Sample Output:
Count: 6
Problem 14: Prime Inspector
Sneha recently discovered prime numbers in her math class. She wants to check whether her
favorite number is prime or not. A prime number is one that has no divisors other than 1 and
itself. Sneha feels proud when she can identify primes quickly. Write a program that helps
Sneha test if the given number N is prime.
Input Format:
One line: Integer N
Output Format:
Prime or Not Prime
Constraints:
2 ≤ N ≤ 1000
Sample Input:
7
Sample Output:
Prime
Problem 15: Prime Range Explorer
Nitin has been given a project to list all prime numbers between 1 and N. He imagines these
primes as “special guardians” in a game, and he needs to know which numbers are guardians.
Instead of checking each number by hand, he wants a program that prints all prime numbers
up to N. Help him generate this prime list quickly.
Input Format:
One line: Integer N
Output Format:
Prime numbers from 1 to N
Constraints:
2 ≤ N ≤ 500
Sample Input:
10
Sample Output:
2
3
5
7
Problem 16: Reverse Number Game
Aarav loves puzzles involving numbers. One of his favorites is reversing the digits of a number.
For instance, if the input is 123, he wants the output to be 321. Aarav thinks of it as turning a
number into its mirror image. Write a program that takes a number N and outputs its reverse
to help Aarav enjoy his game.
Input Format:
One line: Integer N
Output Format:
Reverse:
Constraints:
1 ≤ N ≤ 10^6
Sample Input:
123
Sample Output:
Reverse: 321
Problem 17: Armstrong Detector
Kiran is excited to learn about special numbers. His teacher tells him about Armstrong
numbers—numbers where the sum of their digits each raised to the power of the total digits
equals the number itself. For example, 153 = 1³ + 5³ + 3³. Kiran wants to test different numbers
to see if they are Armstrong numbers. Write a program to help him identify them.
Input Format:
One line: Integer N
Output Format:
Armstrong or Not Armstrong
Constraints:
1 ≤ N ≤ 10^5
Sample Input:
153
Sample Output:
Armstrong
Problem 18: Fibonacci Notebook
Radha is building her collection of interesting number sequences in her notebook. She just
learned about the Fibonacci sequence, where each number is the sum of the two before it.
She wants to write down the first N terms of this sequence to understand its growth. Write a
program to generate the Fibonacci sequence for her.
Input Format:
One line: Integer N
Output Format:
First N Fibonacci terms
Constraints:
1 ≤ N ≤ 30
Sample Input:
5
Sample Output:
0
1
1
2
3
Problem 19: Fibonacci Finder
Shyam is working on a project about number patterns. He doesn’t want the whole sequence
but is particularly interested in knowing the Nth Fibonacci term. For example, the 6th term in
the series is 5. Write a program to calculate the Nth Fibonacci number for Shyam so he can
finish his project on time.
Input Format:
One line: Integer N
Output Format:
Nth Fibonacci number
Constraints:
1 ≤ N ≤ 30
Sample Input:
6
Sample Output:
5
Problem 20: Factorial Sum Collector
Ritu is a curious student who enjoys experimenting with new ideas. Recently, she wondered
what happens if she adds up the factorials of numbers from 1 to N. For instance, with N = 3,
she would calculate 1! + 2! + 3!. She wants to test this idea with larger values of N. Write a
program to calculate the sum of factorials up to N for Ritu.
Input Format:
One line: Integer N
Output Format:
Sum:
Constraints:
1 ≤ N ≤ 10
Sample Input:
3
Sample Output:
Sum: 9
Problem 21: Lucky Ticket Number
Arjun travels to college every day and collects bus tickets. One day, the conductor tells him
that some tickets are considered lucky: if the sum of the first half of the digits equals the sum
of the second half. Intrigued, Arjun wants to check whether his ticket number is lucky or not.
Write a program that helps him test his ticket.
Input Format:
One line: Integer N
Output Format:
Lucky or Not Lucky
Constraints:
N will have an even number of digits
Sample Input:
123321
Sample Output:
Lucky
Problem 22: Even-Odd Sum Race
Maya plays a math game where she separates even and odd numbers from 1 to N. She adds
up the evens and odds separately and compares which sum is larger. For her, it feels like a race
between even and odd numbers to see which side wins. Write a program that calculates both
sums and announces the winner.
Input Format:
One line: Integer N
Output Format:
Even Sum:
Odd Sum:
Constraints:
1 ≤ N ≤ 1000
Sample Input:
10
Sample Output:
Even Sum: 30
Odd Sum: 25
Problem 23: Perfect Square Checker
Dev is learning about perfect squares in school. He knows a perfect square is a number that is
the square of an integer, like 49 = 7 × 7. He wants to write a program to quickly check if a
number is a perfect square so that he can test many numbers in his homework. Help Dev by
writing this checker.
Input Format:
One line: Integer N
Output Format:
Perfect Square or Not Perfect Square
Constraints:
1 ≤ N ≤ 10^6
Sample Input:
49
Sample Output:
Perfect Square
Problem 24: Greatest Common Divisor Hunt
Two friends, Rohit and Sameer, are comparing numbers they like. They want to find out the
greatest common divisor (GCD) of their numbers, which is the largest number that divides
both without a remainder. To avoid lengthy manual calculations, they decide to use a program.
Write a program that calculates the GCD of two numbers using loops.
Input Format:
Two integers A and B
Output Format:
GCD:
Constraints:
1 ≤ A, B ≤ 1000
Sample Input:
20
28
Sample Output:
GCD: 4
Problem 25: Least Common Multiple Hunt
Ananya is working on math problems where she needs to calculate the least common multiple
(LCM) of two numbers. She finds it tiring to calculate manually each time. To save her time,
she decides to build a small program. Write a program that takes two numbers and outputs
their LCM so Ananya can use it for her homework.
Input Format:
Two integers A and B
Output Format:
LCM:
Constraints:
1 ≤ A, B ≤ 1000
Sample Input:
4
6
Sample Output:
LCM: 12
Problem 26: Multiples Explorer
Vivek loves exploring multiplication. His teacher asks him to find all multiples of a number M
up to N. For example, if M = 3 and N = 15, then the multiples are 3, 6, 9, 12, and 15. Write a
program to help Vivek generate this list easily.
Input Format:
Two integers M and N
Output Format:
All multiples of M up to N
Constraints:
1 ≤ M, N ≤ 1000
Sample Input:
3
15
Sample Output:
3
6
9
12
15
Problem 27: Product of Digits
Reema is learning about digit operations. She wants to find the product of digits of a number,
for example, 234 → 2 × 3 × 4 = 24. She finds this interesting because the product changes
drastically depending on the digits. Write a program to calculate the product of digits of a
number N for Reema.
Input Format:
One line: Integer N
Output Format:
Product:
Constraints:
1 ≤ N ≤ 10^6
Sample Input:
234
Sample Output:
Product: 24
Problem 28: Palindrome Range Finder
Arushi enjoys symmetry in numbers. She wants to know all palindrome numbers between 1
and N, where the number reads the same forward and backward. Write a program that prints
all palindromes in this range so that Arushi can create her list of special numbers.
Input Format:
One line: Integer N
Output Format:
All palindrome numbers between 1 and N
Constraints:
1 ≤ N ≤ 1000
Sample Input:
150
Sample Output:
1
2
...
141
Problem 29: Perfect Number Test
Rohini’s math teacher explains perfect numbers to her. A number is called perfect if the sum
of its proper divisors equals the number itself (like 28 = 1 + 2 + 4 + 7 + 14). Rohini wants to
check whether a given number N is perfect. Write a program that helps her test this property.
Input Format:
One line: Integer N
Output Format:
Perfect or Not Perfect
Constraints:
1 ≤ N ≤ 10^5
Sample Input:
28
Sample Output:
Perfect
Problem 30: Strong Number Checker
Kavya is introduced to strong numbers. A number is strong if the sum of the factorials of its
digits equals the number itself (like 145 = 1! + 4! + 5!). She wants to test a number and check
if it is strong. Write a program that helps her do this quickly.
Input Format:
One line: Integer N
Output Format:
Strong or Not Strong
Constraints:
1 ≤ N ≤ 10^5
Sample Input:
145
Sample Output:
Strong
Problem 31: Twin Prime Detector
Rahul learns about twin primes—pairs of prime numbers that differ by 2, like (11, 13). He
wants to find all twin prime pairs up to N. Write a program to help Rahul list them so he can
present it in his class project.
Input Format:
One line: Integer N
Output Format:
All twin prime pairs up to N
Constraints:
2 ≤ N ≤ 500
Sample Input:
20
Sample Output:
(3, 5)
(5, 7)
(11, 13)
(17, 19)
Problem 32: Leap Year Finder
Neha wants to plan her calendar. She needs to check if a given year is a leap year or not. A
leap year is divisible by 4 but not by 100, unless also divisible by 400. Write a program to check
if the year is a leap year.
Input Format:
One line: Integer Year
Output Format:
Leap Year or Not Leap Year
Constraints:
1 ≤ Year ≤ 10^6
Sample Input:
2020
Sample Output:
Leap Year
Problem 33: Largest Number in Range
Arvind wants to identify the largest number between 1 and N that is divisible by 7. Instead of
checking manually, he prefers writing a program. Help Arvind find this largest number so he
can include it in his report.
Input Format:
One line: Integer N
Output Format:
Largest divisible by 7:
Constraints:
1 ≤ N ≤ 1000
Sample Input:
50
Sample Output:
Largest divisible by 7: 49
Problem 34: Smallest Digit Finder
Ishita is practicing digit problems. She wants to find the smallest digit in a given number. For
example, for 9328 the smallest digit is 2. Write a program to help Ishita quickly identify the
smallest digit of N.
Input Format:
One line: Integer N
Output Format:
Smallest Digit:
Constraints:
1 ≤ N ≤ 10^6
Sample Input:
9328
Sample Output:
Smallest Digit: 2
Problem 35: Largest Digit Finder
Kiran wants to play a game of finding the largest digit of a number. For instance, if N = 3852,
then the largest digit is 8. Write a program to find the largest digit for him.
Input Format:
One line: Integer N
Output Format:
Largest Digit:
Constraints:
1 ≤ N ≤ 10^6
Sample Input:
3852
Sample Output:
Largest Digit: 8
Problem 36: Sum of Even Digits
Tanvi is analyzing phone numbers for fun. She wants to add up only the even digits in a
number. For example, for N = 4629, the sum is 4 + 6 + 2 = 12. Write a program to calculate the
sum of even digits in N.
Input Format:
One line: Integer N
Output Format:
Sum of even digits:
Constraints:
1 ≤ N ≤ 10^6
Sample Input:
4629
Sample Output:
Sum of even digits: 12
Problem 37: Sum of Odd Digits
Suresh enjoys working with odd numbers. He wants to find the sum of odd digits of a number.
For example, if N = 7534, then the sum is 7 + 5 + 3 = 15. Write a program to help Suresh
calculate this.
Input Format:
One line: Integer N
Output Format:
Sum of odd digits:
Constraints:
1 ≤ N ≤ 10^6
Sample Input:
7534
Sample Output:
Sum of odd digits: 15
Problem 38: Digit Count Checker
Sanjay is preparing for a quiz. He wants to know how many digits a number has. For example,
12345 has 5 digits. Write a program that counts the digits in N.
Input Format:
One line: Integer N
Output Format:
Count:
Constraints:
1 ≤ N ≤ 10^9
Sample Input:
12345
Sample Output:
Count: 5
Problem 39: Harshad Number Test
Ananya’s teacher introduces Harshad numbers, which are divisible by the sum of their digits.
She wants to test whether N is a Harshad number. Write a program to check this property.
Input Format:
One line: Integer N
Output Format:
Harshad or Not Harshad
Constraints:
1 ≤ N ≤ 10^6
Sample Input:
18
Sample Output:
Harshad
Problem 40: Automorphic Number Test
Nidhi learns about automorphic numbers—numbers whose squares end with the same
number (like 25 → 625). She is curious to test numbers quickly. Write a program to check
whether N is automorphic.
Input Format:
One line: Integer N
Output Format:
Automorphic or Not Automorphic
Constraints:
1 ≤ N ≤ 10000
Sample Input:
25
Sample Output:
Automorphic
Problem 41: Sum of Squares
Rajeev is studying series in math. He wants to calculate the sum of squares of numbers from
1 to N. Write a program that computes this so he can compare results with his textbook.
Input Format:
One line: Integer N
Output Format:
Sum:
Constraints:
1 ≤ N ≤ 1000
Sample Input:
5
Sample Output:
Sum: 55
Problem 42: Sum of Cubes
Arun is curious about cubes of numbers. He wants to calculate the sum of cubes of numbers
from 1 to N. Write a program that helps him quickly get this sum.
Input Format:
One line: Integer N
Output Format:
Sum:
Constraints:
1 ≤ N ≤ 500
Sample Input:
4
Sample Output:
Sum: 100
Problem 43: Co-Prime Check
Manav is learning about co-primes. Two numbers are co-prime if their greatest common
divisor (GCD) is 1. He wants to check whether two given numbers are co-prime. Write a
program to help Manav verify this property.
Input Format:
Two integers A and B
Output Format:
Co-prime or Not Co-prime
Constraints:
1 ≤ A, B ≤ 1000
Sample Input:
8
15
Sample Output:
Co-prime
Problem 44: Prime Factors
Mehul is trying to break down numbers into their building blocks. He wants to find all prime
factors of a number N. Write a program that prints the prime factors of N for Mehul’s study.
Input Format:
One line: Integer N
Output Format:
Prime factors of N
Constraints:
2 ≤ N ≤ 1000
Sample Input:
60
Sample Output:
2
3
5
Problem 45: Number Classification
Poonam’s teacher explains that numbers can be deficient, perfect, or abundant. She wants to
classify a number based on the sum of its divisors (excluding itself). Write a program to classify
N into one of these three categories.
Input Format:
One line: Integer N
Output Format:
Deficient or Perfect or Abundant
Constraints:
1 ≤ N ≤ 1000
Sample Input:
12
Sample Output:
Abundant
Problem 46: Power of Two Test
Sahil is solving puzzles where he must check if a number is a power of two. For example, 8 =
2³ is a power of two. Write a program to determine if N is a power of two.
Input Format:
One line: Integer N
Output Format:
Power of Two or Not Power of Two
Constraints:
1 ≤ N ≤ 10^6
Sample Input:
8
Sample Output:
Power of Two
Problem 47: Power of Three Test
Nisha likes to explore number powers. She wants to check if a given number is a power of
three. For example, 27 = 3³. Write a program that helps her verify this quickly.
Input Format:
One line: Integer N
Output Format:
Power of Three or Not Power of Three
Constraints:
1 ≤ N ≤ 10^6
Sample Input:
27
Sample Output:
Power of Three
Problem 48: Digital Root
Karthik plays with numbers by repeatedly adding digits until only one digit remains. This final
digit is called the digital root. For example, 9875 → 9+8+7+5 = 29 → 2+9 = 11 → 1+1 = 2. Write
a program that finds the digital root of N.
Input Format:
One line: Integer N
Output Format:
Digital Root:
Constraints:
1 ≤ N ≤ 10^9
Sample Input:
9875
Sample Output:
Digital Root: 2
Problem 49: Friendly Pair Check
Aakash is reading about friendly pairs. Two numbers are friendly if their sum of divisors
divided by the number itself is the same. For example, (6, 28) is a friendly pair. Write a program
to check if two numbers form a friendly pair.
Input Format:
Two integers A and B
Output Format:
Friendly Pair or Not Friendly Pair
Constraints:
1 ≤ A, B ≤ 10000
Sample Input:
6
28
Sample Output:
Friendly Pair
Problem 50: Neon Number Test
Swati is told about neon numbers, where the sum of the digits of its square is equal to the
number itself. For example, 9² = 81 → 8+1 = 9. Swati is curious to test this property on
numbers. Write a program to check whether a number is neon or not.
Input Format:
One line: Integer N
Output Format:
Neon or Not Neon
Constraints:
1 ≤ N ≤ 10000
Sample Input:
9
Sample Output:
Neon
Problem 51: Sum of Even Numbers in a Range
Rohit is preparing for his mathematics exam. His teacher asked him to calculate the sum of all
even numbers between two numbers L and R. When the numbers are small, he can add them
manually, but for large ranges he finds it difficult. He now wants to write a program using loops
that can calculate the result efficiently. Help Rohit in solving his homework.
Input Format:
Two integers: L, R
Output Format:
Sum of evens:
Constraints:
1 ≤ L ≤ R ≤ 1000
Sample Input:
1 10
Sample Output:
Sum of evens: 30
Problem 52: Sum of Odd Numbers in a Range
Sneha loves working with odd numbers. In her assignment, she has been asked to find the
total sum of odd numbers between two given values L and R. She knows the logic but struggles
when the range is large. She decides to use loops to quickly compute the sum. Write a program
that will assist Sneha in calculating the result.
Input Format:
Two integers: L, R
Output Format:
Sum of odds:
Constraints:
1 ≤ L ≤ R ≤ 1000
Sample Input:
1 10
Sample Output:
Sum of odds: 25
Problem 53: Count Multiples of 3
During a classroom activity, children are asked to clap every time a number is a multiple of 3.
The teacher gives a maximum number N, and the students must figure out how many times
they will clap. Instead of counting manually, Ramesh wants to use a program to determine
how many multiples of 3 exist between 1 and N. Write the loop-based solution for him.
Input Format:
One integer: N
Output Format:
Count:
Constraints:
1 ≤ N ≤ 10000
Sample Input:
10
Sample Output:
Count: 3
Problem 54: Sum of Squares in a Range
Anjana, a math enthusiast, is given a task to find the sum of squares of all numbers between
two values L and R. She realizes that calculating each square and then adding them is time-
consuming when the range is large. She decides to write a loop-based program to complete
her assignment faster. Help her by writing the code.
Input Format:
Two integers: L, R
Output Format:
Sum of squares:
Constraints:
1 ≤ L ≤ R ≤ 1000
Sample Input:
15
Sample Output:
Sum of squares: 55
Problem 55: Sum of Cubes in a Range
Ravi is solving puzzles related to cubes. His teacher asked him to find the sum of cubes of
numbers from L to R. Doing it manually would take a lot of time, so Ravi decides to write a
small program that can calculate the result using loops. Your task is to help him finish his work
quickly.
Input Format:
Two integers: L, R
Output Format:
Sum of cubes:
Constraints:
1 ≤ L ≤ R ≤ 200
Sample Input:
13
Sample Output:
Sum of cubes: 36
Problem 56: Factor Listing
Arjun is given a homework problem to list all the factors of a number N. At first, he tries
dividing the number by hand, but soon realizes it is slow and tiring for big numbers. He wants
to create a program using loops that prints all the factors of a number in ascending order.
Write a solution for Arjun.
Input Format:
One integer: N
Output Format:
Factors:
Constraints:
1 ≤ N ≤ 1000
Sample Input:
12
Sample Output:
Factors: 1 2 3 4 6 12
Problem 57: Count Factors of a Number
Meena is studying divisibility. She was given a challenge to count how many factors a given
number N has. She finds it tricky when the number is large, so she thinks of using a program
that can calculate it with loops. Write a program to count the number of factors of N for
Meena.
Input Format:
One integer: N
Output Format:
Count:
Constraints:
1 ≤ N ≤ 1000
Sample Input:
12
Sample Output:
Count: 6
Problem 58: Perfect Number Check
In her number theory class, Shalini learned about perfect numbers. A number is called perfect
if the sum of its proper divisors equals the number itself. She is curious to check whether a
given number N is perfect or not. Since testing big numbers is hard manually, she wants to
write a loop-based program. Can you help her?
Input Format:
One integer: N
Output Format:
Perfect or Not Perfect
Constraints:
1 ≤ N ≤ 10000
Sample Input:
28
Sample Output:
Perfect
Problem 59: Strong Number Check
A strong number is one where the sum of the factorials of its digits equals the number itself.
In a quiz competition, students were asked to test whether a number is strong or not. Ravi
decides to solve it using a program rather than doing repeated calculations. Write a loop-
based solution for him.
Input Format:
One integer: N
Output Format:
Strong or Not Strong
Constraints:
1 ≤ N ≤ 100000
Sample Input:
145
Sample Output:
Strong
Problem 60: Neon Number Check
Neha is curious about special numbers. She read about neon numbers, which are numbers
where the sum of digits of the square equals the number itself. Instead of checking manually,
she decides to use loops to build a small program. Write a program to help Neha test whether
N is neon or not.
Input Format:
One integer: N
Output Format:
Neon or Not Neon
Constraints:
1 ≤ N ≤ 10000
Sample Input:
9
Sample Output:
Neon
Problem 61: Automorphic Number
In mathematics class, Sameer came across the concept of automorphic numbers. A number is
called automorphic if its square ends with the same digits as the number itself. Curious to test
this property, Sameer wants to write a program that checks whether a number N is
automorphic or not using loops. Help him with this task.
Input Format:
One integer: N
Output Format:
Automorphic or Not Automorphic
Constraints:
1 ≤ N ≤ 10000
Sample Input:
25
Sample Output:
Automorphic
Problem 62: Palindrome Number
Palak finds palindromes very interesting. A number is called palindrome if it reads the same
backward as forward. For her assignment, she is asked to check whether a given number is a
palindrome. She decides to write a program using loops instead of reversing digits manually.
Write a program to help Palak.
Input Format:
One integer: N
Output Format:
Palindrome or Not Palindrome
Constraints:
1 ≤ N ≤ 100000
Sample Input:
121
Sample Output:
Palindrome
Problem 63: Armstrong Number
Input Format:
One integer: N
Output Format:
Armstrong or Not Armstrong
Constraints:
1 ≤ N ≤ 100000
Sample Input:
153
Sample Output:
Armstrong
Problem 64: Reverse of a Number
Ravi enjoys reversing numbers. His teacher gave him a homework assignment to reverse the
digits of a number. He knows it can be done by repeatedly extracting digits but wants to
implement it with loops. Write a program to help Ravi reverse a number N.
Input Format:
One integer: N
Output Format:
Reverse:
Constraints:
1 ≤ N ≤ 100000
Sample Input:
1234
Sample Output:
Reverse: 4321
Problem 65: Sum of Digits
In a puzzle game, Riya has to find the sum of digits of a number N. She realizes this can be
solved by repeatedly taking digits out using modulus and division. Instead of doing it by hand,
she decides to write a program using loops. Write a program to calculate the digit sum of N.
Input Format:
One integer: N
Output Format:
Digit Sum:
Constraints:
1 ≤ N ≤ 100000
Sample Input:
1234
Sample Output:
Digit Sum: 10
Problem 66: Product of Digits
Manoj is fascinated with digit multiplications. He wants to calculate the product of digits of a
number N. He knows that using loops will make it easier for any number size. Write a program
for Manoj to compute the product of digits.
Input Format:
One integer: N
Output Format:
Product:
Constraints:
1 ≤ N ≤ 100000
Sample Input:
234
Sample Output:
Product: 24
Problem 67: Digit Count
Rekha’s younger brother asked her how many digits are in a number. She decides to solve this
problem by writing a loop that counts digits one by one until the number becomes zero. Write
a program to count the digits of N.
Input Format:
One integer: N
Output Format:
Digits:
Constraints:
1 ≤ N ≤ 10^9
Sample Input:
9876
Sample Output:
Digits: 4
Problem 68: Largest Digit
While playing with numbers, Amit wants to find the largest digit in a number N. He starts by
checking each digit one by one and compares them. To make the task efficient, he decides to
write a program using loops. Write a program to find the largest digit.
Input Format:
One integer: N
Output Format:
Largest digit:
Constraints:
1 ≤ N ≤ 100000
Sample Input:
5892
Sample Output:
Largest digit: 9
In her practice session, Neha was asked to find the smallest digit of a number N. She realizes
that checking digit by digit with loops is the easiest way. Write a program to help Neha find
the smallest digit.
Input Format:
One integer: N
Output Format:
Smallest digit:
Constraints:
1 ≤ N ≤ 100000
Sample Input:
5892
Sample Output:
Smallest digit: 2
Problem 70: HCF of Two Numbers
Arun is working on fractions and needs to find the highest common factor (HCF) of two
numbers. He knows this can be done by checking divisibility using loops. Write a program to
calculate the HCF of two numbers.
Input Format:
Two integers: A, B
Output Format:
HCF:
Constraints:
1 ≤ A, B ≤ 10000
Sample Input:
20 30
Sample Output:
HCF: 10
Problem 71: LCM of Two Numbers
Kiran is solving math problems related to multiples. He wants to calculate the least common
multiple (LCM) of two numbers. Instead of manually listing multiples, he wants to use loops.
Write a program to find the LCM of two numbers.
Input Format:
Two integers: A, B
Output Format:
LCM:
Constraints:
1 ≤ A, B ≤ 10000
Sample Input:
46
Sample Output:
LCM: 12
Problem 72: Sum of Even Digits
In a puzzle book, Pooja read a question asking her to find the sum of all even digits in a number
N. She decides to solve it using a loop where each digit is extracted and checked. Write a
program to find the sum of even digits.
Input Format:
One integer: N
Output Format:
Sum of even digits:
Constraints:
1 ≤ N ≤ 100000
Sample Input:
24567
Sample Output:
Sum of even digits: 12
Problem 73: Sum of Odd Digits
Ramesh is challenged by his teacher to find the sum of odd digits of a number. He knows that
this can be done by checking each digit with a loop. Write a program to calculate the sum of
odd digits in number N.
Input Format:
One integer: N
Output Format:
Sum of odd digits:
Constraints:
1 ≤ N ≤ 100000
Sample Input:
24567
Sample Output:
Sum of odd digits: 18
Problem 74: Power Calculation
Ankita wants to calculate A raised to the power B, but she does not want to use the built-in
power function. She decides to use loops and multiply the number A repeatedly B times. Write
a program to calculate the result.
Input Format:
Two integers: A, B
Output Format:
Result:
Constraints:
1 ≤ A ≤ 1000, 0 ≤ B ≤ 20
Sample Input:
25
Sample Output:
Result: 32
Problem 75: Digit Frequency
During a quiz, Ansh was asked to count how many times a particular digit D appears in number
N. He knows this requires checking every digit, so he writes a loop to count occurrences. Write
a program to calculate the frequency of digit D in N.
Input Format:
Two integers: N, D
Output Format:
Frequency:
Constraints:
1 ≤ N ≤ 10^9, 0 ≤ D ≤ 9
Sample Input:
122333 3
Sample Output:
Frequency: 3
Problem 76: Harshad Number
In number theory, Harshad numbers are divisible by the sum of their digits. Deepak wants to
check if a number N is Harshad or not. He decides to use a loop to calculate the digit sum and
then check divisibility. Write a program for him.
Input Format:
One integer: N
Output Format:
Harshad or Not Harshad
Constraints:
1 ≤ N ≤ 10000
Sample Input:
18
Sample Output:
Harshad
Problem 77: Fibonacci Series up to N Terms
Rohit is fascinated by the Fibonacci series. His teacher asks him to print the first N terms of
the series. Rohit knows this can be done with loops by adding previous two terms repeatedly.
Write a program to generate the Fibonacci series.
Input Format:
One integer: N
Output Format:
Series:
Constraints:
1 ≤ N ≤ 50
Sample Input:
5
Sample Output:
Series: 0 1 1 2 3
Problem 78: Prime Numbers in a Range
Prerna wants to find all prime numbers between two numbers L and R. She knows this requires
checking divisibility using loops. Write a program to list all prime numbers in the range.
Input Format:
Two integers: L, R
Output Format:
Primes:
Constraints:
1 ≤ L ≤ R ≤ 1000
Sample Input:
10 20
Sample Output:
Primes: 11 13 17 19
Problem 79: Count Prime Numbers in a Range
During exam practice, Suman is asked to count how many prime numbers lie between L and
R. She decides to write a program using loops to test each number. Write a program to count
primes in the range.
Input Format:
Two integers: L, R
Output Format:
Count:
Constraints:
1 ≤ L ≤ R ≤ 1000
Sample Input:
1 10
Sample Output:
Count: 4
Problem 80: Prime Factorization
Arjun is learning factorization. His teacher asks him to find all prime factors of a number N. He
realizes he can do this by repeatedly dividing the number using loops. Write a program for
prime factorization.
Input Format:
One integer: N
Output Format:
Prime factors:
Constraints:
2 ≤ N ≤ 10000
Sample Input:
60
Sample Output:
Prime factors: 2 3 5
Problem 81: Perfect Squares in a Range
Meena is solving a number puzzle. She is asked to print all perfect squares between two
numbers L and R. She wants to solve it using loops instead of calculating manually. Write a
program to help Meena.
Input Format:
Two integers: L, R
Output Format:
Squares:
Constraints:
1 ≤ L ≤ R ≤ 1000
Sample Input:
1 50
Sample Output:
Squares: 1 4 9 16 25 36 49
Problem 82: Perfect Cubes in a Range
Raghav’s assignment is to print all perfect cubes between two numbers. He knows that by
using loops, he can check cube values one by one. Write a program to generate all perfect
cubes between L and R.
Input Format:
Two integers: L, R
Output Format:
Cubes:
Constraints:
1 ≤ L ≤ R ≤ 1000
Sample Input:
1 30
Sample Output:
Cubes: 1 8 27
Problem 83: GCD of Three Numbers
In her exam, Shruti was asked to find the greatest common divisor (GCD) of three numbers.
She recalls that this can be solved by repeatedly checking divisors using loops. Write a program
to find the GCD of A, B, and C.
Input Format:
Three integers: A, B, C
Output Format:
GCD:
Constraints:
1 ≤ A, B, C ≤ 10000
Sample Input:
12 18 24
Sample Output:
GCD: 6
Problem 84: Palindromes in a Range
Sneha is working on palindromes. She is asked to list all palindrome numbers between L and
R. She wants to automate this task using loops so that she can easily test large ranges. Write
a program to print all palindrome numbers in the given range.
Input Format:
Two integers: L, R
Output Format:
Palindromes:
Constraints:
1 ≤ L ≤ R ≤ 1000
Sample Input:
10 200
Sample Output:
Palindromes: 11 22 33 44 55 66 77 88 99 101 111 121 131 141 151 161 171 181 191
Problem 85: Strong Numbers in a Range
Vikas has recently learned about strong numbers. His teacher now challenges him to find all
strong numbers between two values L and R. Doing this manually for each number is very
time-consuming. Vikas decides to use loops to test each number one by one and print all
strong numbers. Write a program for him.
Input Format:
Two integers: L, R
Output Format:
Strong Numbers:
Constraints:
1 ≤ L ≤ R ≤ 100000
Sample Input:
1 200
Sample Output:
Strong Numbers: 1 2 145
Problem 86: Sum of Digits of All Numbers in a Range
Anita’s teacher asked her to calculate the sum of digits for all numbers between L and R. She
finds this boring to do manually and decides to solve it with a program that uses loops. Write
a program to compute the total digit sum from L to R.
Input Format:
Two integers: L, R
Output Format:
Total Digit Sum:
Constraints:
1 ≤ L ≤ R ≤ 1000
Sample Input:
10 15
Sample Output:
Total Digit Sum: 21
Problem 87: Count Palindromes in a Range
Rahul is preparing for a coding competition. One of the problems asks him to count how many
palindrome numbers lie between L and R. He knows that checking each number with loops is
the best approach. Write a program to count all palindromes in the range.
Input Format:
Two integers: L, R
Output Format:
Count:
Constraints:
1 ≤ L ≤ R ≤ 2000
Sample Input:
10 150
Sample Output:
Count: 19
Problem 88: Special Two-Digit Numbers
In a math contest, students were asked to find all two-digit numbers where the number is
equal to the sum of the squares of its digits. Ankit is curious to solve this problem using loops.
Write a program to find all such numbers.
Input Format:
No input required
Output Format:
Special numbers:
Sample Output:
Special numbers: 81
Problem 89: Nth Fibonacci Term
Shreya loves the Fibonacci series. This time, instead of printing the whole series, her teacher
asks her to find the Nth term. She decides to solve it using a loop by building the series up to
N. Write a program for Shreya.
Input Format:
One integer: N
Output Format:
Nth term:
Constraints:
1 ≤ N ≤ 50
Sample Input:
7
Sample Output:
Nth term: 8
Problem 90: Factorial of Digits Sum
Rohit’s puzzle asks him to calculate the sum of factorials of digits of a number N. He knows
this can be done by extracting each digit and calculating its factorial in a loop. Write a program
to help him.
Input Format:
One integer: N
Output Format:
Sum:
Constraints:
1 ≤ N ≤ 100000
Sample Input:
123
Sample Output:
Sum: 9
Problem 91: Prime Digits Count
Anjali is learning about prime digits. She is given a number N and asked to count how many of
its digits are prime (2, 3, 5, 7). She decides to use loops to extract each digit and check. Write
a program to count prime digits.
Input Format:
One integer: N
Output Format:
Count:
Constraints:
1 ≤ N ≤ 100000
Sample Input:
25741
Sample Output:
Count: 3
Problem 92: Composite Digits Count
Sahil is exploring numbers and wants to know how many digits of a number are composite
(like 4, 6, 8, 9). He decides to solve it using a loop. Write a program to count composite digits
in number N.
Input Format:
One integer: N
Output Format:
Count:
Constraints:
1 ≤ N ≤ 100000
Sample Input:
8642
Sample Output:
Count: 3
Problem 93: Kaprekar Number
During a math fest, students were introduced to Kaprekar numbers. A number is Kaprekar if
the sum of parts of its square equals the number itself. Priya wants to write a loop-based
program to check whether N is Kaprekar or not. Write the solution.
Input Format:
One integer: N
Output Format:
Kaprekar or Not Kaprekar
Constraints:
1 ≤ N ≤ 10000
Sample Input:
45
Sample Output:
Kaprekar
Problem 94: Magic Number
A magic number is one where the recursive sum of its digits reduces to 1. Manish is curious
about such numbers and wants to test them. Write a loop-based program to check whether a
number N is magic or not.
Input Format:
One integer: N
Output Format:
Magic or Not Magic
Constraints:
1 ≤ N ≤ 10000
Sample Input:
19
Sample Output:
Magic
Problem 95: Duck Number
Sanya learned about duck numbers. A number that contains zeroes (but not starting with zero)
is called a duck number. She wants to write a program using loops to check whether a number
N is duck or not. Write the code.
Input Format:
One integer: N
Output Format:
Duck or Not Duck
Constraints:
1 ≤ N ≤ 100000
Sample Input:
1203
Sample Output:
Duck
Problem 96: Evil Number
An evil number is one whose binary representation contains an even number of 1’s. Ashok
wants to write a loop-based program to test whether N is an evil number or not. Write a
program to help him.
Input Format:
One integer: N
Output Format:
Evil or Not Evil
Constraints:
1 ≤ N ≤ 1000
Sample Input:
9
Sample Output:
Evil
Problem 97: Happy Number
Input Format:
One integer: N
Output Format:
Happy or Not Happy
Constraints:
1 ≤ N ≤ 10000
Sample Input:
19
Sample Output:
Happy
Problem 98: Spy Number
A spy number is one where the sum of its digits equals the product of its digits. Meena is
curious to test such numbers and decides to use loops. Write a program to check if N is a spy
number.
Input Format:
One integer: N
Output Format:
Spy or Not Spy
Constraints:
1 ≤ N ≤ 100000
Sample Input:
1124
Sample Output:
Spy
Problem 99: Twin Primes in a Range
Reena read about twin primes — pairs of primes differing by 2. She wants to find all twin
primes between L and R. She knows this requires checking each number using loops. Write a
program to print all twin primes.
Input Format:
Two integers: L, R
Output Format:
Twin Primes:
Constraints:
1 ≤ L ≤ R ≤ 1000
Sample Input:
2 20
Sample Output:
Twin Primes: (3,5) (5,7) (11,13) (17,19)
Problem 100: Co-Prime Check
In a programming contest, Arjun is asked to check if two numbers are co-prime (i.e., their HCF
is 1). He decides to use loops to calculate the HCF and then verify. Write a program to check if
two numbers are co-prime.
Input Format:
Two integers: A, B
Output Format:
Co-Prime or Not Co-Prime
Constraints:
1 ≤ A, B ≤ 10000
Sample Input:
14 15
Sample Output:
Co-Prime