Find the number of occurrences of a given character in a string
For a specified string, we would need to find out how many times an input character occurs in the string. For example, in a string "amigo baltigo jijutsu" the character i occurs 3 times. We would need to print the count for every input of a string and a character.
Find the reverse of given number
For any given number we would need to return the number in reverse, with the starting place to the end place. For example, for an input of 1423 we would need to return 3241 which is its exact reverse. To achieve this, we would use the same principle we use for splitting the number; the Divisibility by 10 rule.
Find the Factorial of a given number using Recursion
Factorial of a number is calculated by multiplying all the numbers from 1 till the number itself. For any given input number, we are required to calculate factorial, using recursion. Recursion is a technique in which a method calls itself in a loop until some breaking statement is met. This technique makes programming significantly simple and is used in complex computations to save memory.
Check if a given string is Palindrome
A Palindrome is defined as a phrase or a number which when reversed also gives the same phrase or number. For example, the word abcdcba is a palindrome because even when you read the string from end to the beginning you'll get the same string as the original. Some real words such as malayalam, madam, refer, reviver, noon, mom and such are all palindromes in general use.
Find if the given number is a Perfect Number
A Perfect Number is a positive integer for which the sum of all of its positive factors except the number results in the number itself. For example, 6 is a perfect number because the factors of 6 excluding itself are 1, 2, 3 and sum of them is itself - 6. To achieve this, we shall make use of the factors logic and find the sum of all factors except the number itself and check if the sum is equal to the number or not.
Find if the given number is a Palindrome
A Palindrome is defined as a phrase or a number which when reversed also gives the same phrase or number. For example: 14341 when reversed results in 14341 which is same as the original number. Which is what we call a palindrome. In order to achieve this, we extend our logic to reverse a given number to add a little condition at the end to check if the created number is equal to the input number or not. If equal it means that the input number was a palindrome, else not.
Find if the given number is an Armstrong Number
A number is called an Armstrong Number or Narcissistic number if the sum of its own digits raised to the power of the number of digits equals to the number. For example, 371 = 3^3 + 7^3 + 1^3 = 27 + 343 + 1 By logic, all single digit numbers are Armstrong numbers since n^1 = n. For a given number, we would need to find out if the given number is an Armstrong number or not.
Find the number of digits of a given number
For any given number greater than 9, we would need to find the number of digits present in the number by pure logic. For this, we would use the standard divisibility rule of 10 in which when a number is divided by 10 the last digit of the number is returned as the remainder and the remaining digits are returned as the quotient. For example : 6234 divided by 10 leaves 4 as remainder since 10 divides 6234 by 623 times. We use this rule to strip the numbers and count them.
Find if the given number is a Perfect Square
A Perfect square is a whole number which is produced by multiplying two equal integers. In other words, a number which has a square root as an integer is called a Perfect square. Examples are 1, 4, 9, 25, .. and such. For any given number, we would need to find if there is a number which multiplied by itself results in the same number.
Find all the Fibonacci numbers for a given limit
Fibonacci numbers are a series of numbers in which each number is formed by adding previous two numbers in the series. For example, we start by 1 and 2, and then repetitively add the add the numbers to result in the next number. For a given max limit 10, we would want to find the first 10 Fibonacci numbers. Series: 1,2,3,5,8,13,21,34,55,89
We use cookies to provide you with a great user experience, analyze traffic and serve targeted promotions.   Learn More   Accept