C++ Program to Display Fibonacci Series

Samual Sam
Updated on 23-Jun-2020 16:24:22

16K+ Views

The fibonacci series contains numbers in which each term is the sum of the previous two terms. This creates the following integer sequence −0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377…….The recurrence relation that defines the fibonacci numbers is as follows −F(n) = F(n-1) + F(n-2) F(0)=0 F(1)=1Programs to Display Fibonacci SeriesThere are two methods to display fibonacci series i.e. using dynamic programming and recursive programming. These are further explained as follows −Dynamic ProgrammingExample#include using namespace std; void fib(int n) {    int f[n];    int i;    f[0] = 0;    f[1] ... Read More

Specify Bottom Position of 3D Elements with CSS

Sreemaha
Updated on 23-Jun-2020 16:24:15

426 Views

To specify the bottom position of 3D elements, use the perspective-origin property.You can try to run the following code to implement the perspective-origin property:ExampleLive Demo                     .demo1 {             position: relative;             width: 150px;             height: 150px;             background-color: yellow;             perspective: 80px;             margin: 50px;             perspective-origin: left;          }          .demo2 {             position: absolute;             padding: 20px;             background-color: orange;             transform-style: preserve-3d;             transform: rotateX(45deg);          }                     Rotation       Demo          Demo                

Find Duplicate Rows in a Binary Matrix using Python

Paul Richard
Updated on 23-Jun-2020 16:19:16

378 Views

Given a binary matrix contains 0 and 1, our task is to find duplicate rows and print it.Python provides Counter() method which is used here.ExampleInput: 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 Output: (1, 1, 1, 1) (0, 0, 0, 0)AlgorithmStep 1: Create a binary matrix, only 0 and 1 elements are present. Step 2: Which will have rows as key and it’s frequency as value. Lists are mutable so first, we will cast each row (list) into a tuple. Step 3: Create a dictionary using the counter method. Step 4: ... Read More

Select Elements with a Specified Attribute and Value using CSS

Nitya Raut
Updated on 23-Jun-2020 16:18:28

259 Views

Use the [attribute = ”value”] selector to select elements with a specified attribute and value.You can try to run the following code to implement the CSS [attribute = "value"] Selector. Here, we have considered the attribute as rel,Example:Live Demo                 a[rel = nofollow] {          border: 3px solid blue;       }                     Uber's Business Model       Share Market    

Role of CSS Selector

Ankith Reddy
Updated on 23-Jun-2020 16:15:32

3K+ Views

Use the [attribute=”value”] selector to select elements with a specified attribute and value.You can try to run the following code to implement the CSS [attribute="value"] Selector. Here, we have considered the attribute as rel,ExampleLive Demo                    a[rel = nofollow] {             border: 3px solid orange;          }                     Uber's Business Model       Share Market    

Count Total Set Bits in Numbers from 1 to N in Python

Paul Richard
Updated on 23-Jun-2020 16:12:51

346 Views

Given a positive integer n, then we change to its binary representation and count the total number of set bits.ExampleInput : n=3 Output : 4AlgorithmStep 1: Input a positive integer data. Step 2: then convert it to binary form. Step 3: initialize the variable s = 0. Step 4: traverse every element and add. Step 5: display sum.Example Code# Python program to count set bits # in all numbers from 1 to n. def countbits(n):    # initialize the counter    c = 0    for i in range(1, n + 1):    c += bitsetcount(i)    return c    def bitsetcount(x):       if (x

Check If a Given String is Heterogram in Python

Rishi Raj
Updated on 23-Jun-2020 16:12:12

2K+ Views

Here one string is given then our task is to check weather a given string is Heterogram or not.The meaning of heterogram checking is that a word, phrase, or sentence in which no letter of the alphabet occurs more than once. A heterogram may be distinguished from a pangram which uses all of the letters of the alphabet.ExampleString is abc def ghiThis is Heterogram (no alphabet repeated)String is abc bcd dfhThis is not Heterogram. (b, c, d are repeated)AlgorithmStep 1: first we separate out list of all alphabets present in sentence. Step 2: Convert list of alphabets into set because ... Read More

Find Largest, Smallest, Second Largest and Second Smallest in a List

karthikeya Boyini
Updated on 23-Jun-2020 16:11:30

2K+ Views

Array is given, we have to find out maximum, minimum, secondlargest, second smallest number.AlgorithmStep 1: input list element Step 2: we take a number and compare it with all other number present in the list. Step 3: get maximum, minimum, secondlargest, second smallest number.Example code# To find largest, smallest, second largest and second smallest in a List    def maxmin(A):       maxi = A[0]       secondsmax = A[0]       mini = A[0]       secondmini = A[0]       for item in A:    if item > maxi:       maxi ... Read More

Select Elements with a Specified Attribute using CSS

Giri Raju
Updated on 23-Jun-2020 16:09:58

209 Views

To select elements with an attribute, use the CSS [attribute] selector.For example, alt attribute or a target attribute, etc.You can try to run the following code to implement the CSS[attribute] selector,ExampleLive Demo                    img[alt] {             border: 3px solid orange;          }                              

Print Common Characters of Two Strings in Alphabetical Order

karthikeya Boyini
Updated on 23-Jun-2020 16:09:56

1K+ Views

Two user input strings are given, our task is to print all the common characters in alphabetical order.ExampleInput: string1: python string2: program Output: opExplanationThe letters that are common between the two strings are o (1 times), p (1 time)AlgorithmStep 1: first we take two input string. Step 2: next we will do to convert these two strings into counter dictionary. Step 3: Now find common elements between two strings using intersection ( ) property. Step 4: Resultant will also be a counter dictionary having common elements as keys and their common frequencies as value. Step 5: Use elements () method ... Read More

Advertisements