Skip to main content

Numbers

Programming Questions on Numbers


1) Given a number find the sum of all digits in a number
    Input: n = 1234 output: 10
    Explanation: 1+2+3+4 = 10

2) Given a number check given number is palindrome or not
     Input: n = 12321     output: Palindrome
     Input: n = 123         output: not Palindrome

3) Given a number increase each digit by 1 if the digit is 9 make it 0
    Input: n = 1798      output: 2809
    Explanation:  1 is increased by 1 becomes 2 and the same for the rest of the digits.

4) Given a number find the prime sum
    Input: n = 2345       output: 10
    Explanation: In the given digits 2,3 and 5 are prime digits so find the sum all prime numbers.

5) Find the biggest of 3 numbers
    Input: a=10, b=20, c=15 output: Biggest is 20

6) Find the highest frequency of digit in a given number
    Input: n = 1998    output: 9
    Explanation: In 1998 , most repeated digit is 9

7) Find a repeated digit in a given number
    Input: 2020       output: 2,0

 8) Check the given year is a leap year or not
    Input: 2017     output: NO

9) Given a number N( 111 <=  N <= 999) perform the sum  based on the following condition
 N = 234, in a given number N, 4 is the last digit find the sum for 4 times like
  1. 2+3=5
  2. 5+3=8
  3. 8+3=11
  4. 11+3=14.
So the final output is 14.

10) Find the sum of all digits in a given number based on the following conditions
N = 345, perform 3+0 = 3 , 4+3 = 7, 5+7 = 12 , now we got M = 3712, now find the sum of digits in M and output will be 13.

11)Find the nth Fibonacci number




Some more questions will be added soon.
     

Cheers keep coding

Comments

  1. It is actually a nice and useful information. I'm glad that you shared this useful information .Thanks for sharing.https://www.acte.in/java-training-in-pune

    ReplyDelete

Post a Comment