Here we will see how to get the unit place digit of the sum of N factorials. So if N is 3, then after getting sum, we will get 1! + 2! + 3! = 9, this will be the result, for N = 4, it will be 1! + 2! + 3! + 4! = 33. so unit place is 3. If we see this clearly, then as the factorials of N > 5, the unit place is 0, so after 5, it will not contribute to change the unit place. For N = 4 and more, it will ... Read More
Suppose we have an array. There are n different elements. We have to check the frequency of one element in the array. Suppose A = [5, 12, 26, 5, 3, 4, 15, 5, 8, 4], if we try to find the frequency of 5, it will be 3.To solve this, we will scan the array from left, if the element is the same as the given number, increase the counter, otherwise go for the next element, until the array is exhausted.Example Live Demo#include using namespace std; int countElementInArr(int arr[], int n, int e) { int count = 0; for(int i = 0; i
Here we will see how to get the frequency of a digit in a number. Suppose a number is like 12452321, the digit D = 2, then the frequency is 3.To solve this problem, we take the last digit from the number, then check whether this is equal to d or not, if so then increase the counter, then reduce the number by dividing the number by 10. This process will be continued until the number is exhausted.Example Live Demo#include using namespace std; int countDigitInNum(long long number, int d) { int count = 0; while(number){ if((number ... Read More
The HTML DOM Ul Object in HTML represents the element.Creating a elementvar ulObject = document.createElement(“UL”)Here, “ulObject” can have the following properties but are not supported in HTML5 −PropertyDescriptioncompactItsets/returns whether the unordered list should be displayedsmaller than usualtypeItsets/returns the value of the type attribute of an unordered listLet us see an example of unordered list element −Example Live Demo Ul item() form { width:70%; margin: 0 auto; text-align: center; } * { padding: 2px; margin:5px; } input[type="button"] ... Read More
Suppose we have a string; we have to find the first character that is repeated. So is the string is “Hello Friends”, the first repeated character will be l. As there are two l’s one after another.To solve this, we will use the hashing technique. Create one hash table, scan each character one by one, if the character is not present, then insert into a hash table, if it is already present, then return that character.Example Live Demo#include #include using namespace std; char getFirstRepeatingChar(string &s) { unordered_set hash; for (int i=0; i
In this section, we will see how to find factorial of a number using the PL/SQL. In PL/SQL code, some group of commands is arranged within a block of the related declaration of statements.Factorial of a number is basically multiplication of all integers from 1 to n, where n is the given number. So n! = n * (n – 1) * (n – 2) * … * 2 * 1.Example (PL/SQL) Live DemoDECLARE fact number :=1; n number := &1; BEGIN while n > 0 loop fact:=n*fact; n:=n-1; end loop; dbms_output.put_line(fact); END;OutputConsider 5 has given 120
In this section, we will see how we can get the sum of all odd prime factors of a number in an efficient way. There is a number say n = 1092, we have to get all factors of this. The prime factors of 1092 are 2, 2, 3, 7, 13. The sum of all odd factors is 3+7+13 = 23. To solve this problem, we have to follow this rule −When the number is divisible by 2, ignore that factor, and divide the number by 2 repeatedly.Now the number must be odd. Now starting from 3 to square root ... Read More
The HTML DOM Underline Object in HTML represents the element.Creating a elementvar uObject = document.createElement(“U”)Let us see an example of Underline element −Example Live Demo HTML DOM Underline form { width:70%; margin: 0 auto; text-align: center; } * { padding: 2px; margin:5px; } input[type="button"] { border-radius: 10px; } HTML-DOM-Underline Warning: This is a Demo Example var uObject = document.getElementById("Underline"); function getBetterDisp() { uObject.style.backgroundColor = '#DC3545'; uObject.style.color = '#FFF'; } OutputBefore clicking show button −After clicking show button −
In this section, we will see how we can get the sum of all even prime factors of a number in an efficient way. There is a number say n = 480, we have to get all factors of this. The prime factors of 480 are 2, 2, 2, 2, 2, 3, 5. The sum of all even factors is 2+2+2+2+2 = 10. To solve this problem, we have to follow this rule −When the number is divisible by 2, add them into the sum, and divide the number by 2 repeatedly.Now the number must be odd. So we will ... Read More
This program is used to find all the even factors and calculate the sum of these even factors and display it as output.Example −Input : 30 Even dividers : 2+6+10+30 = 48 Output : 48For this, we will find all the factors. Find the even of them and find the sum, Else, we will use the formula to find the sum of factors using the prime factors, Sum of divisors = (1 + d11 + d12 ... d1a1) *(1 + d21 + d22 ... d2a2) *...........................* (1 + dk1 + dk2 ... dkak) Here di = prime factors ; ai ... Read More
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP