Posts

Showing posts from May, 2020

Question Set 5

“Simplicity is prerequisite for reliability.” — Edsger Dijkstra Problem 1-Fibonacci Series (Easy) The Fibonacci sequence is a series where the next term is the sum of previous two terms. The first two terms of the Fibonacci sequence is 0 followed by 1.Print Fibonacci Series upto a number n. 0,1,1,2,3,5,8,13,..... Link to question- https://www.programiz.com/cpp-programming/examples/fibonacci-series Problem 2-Factorial (Easy) Factorial of a non-negative integer, is multiplication of all integers smaller than or equal to n. For example factorial of 6 is 6*5*4*3*2*1 which is 720. Find factorial of a number N. Link to question- https://www.geeksforgeeks.org/program-for-factorial-of-a-number/ Problem 3-Primality Test (Easy) Given a positive integer, check if the number is prime or not. A prime is a natural number greater than 1 that has no positive divisors other than 1 and itself. Examples of first few prime numbers are 2, 3, 5, 7, 11 ..... Link to question- https://www.geeksforgeeks.org/pr

Question Set 4

  This is question set 4. Another day another set.This set contains 3 questions from the famous CSES problems set.This set has some problems that new programmers must give a try. Happy Coding! "while(!success) keep trying”   Problem 1- Repetitions (Easy) You are given a DNA sequence: a string consisting of characters A, C, G, and T. Your task is to find the longest repetition in the sequence. This is a maximum-length substring containing only one type of character. The only input line contains a string of n characters. Print one integer: the length of the longest repetition. Constraints 1 ≤ n≤ 10^6 Example Input: ATTCGGGA Output: 3 Link to the question- https://cses.fi/problemset/task/1069   Problem 2-Weird Algorithm (Easy) Consider an algorithm that takes as input a positive integer n. If n is even, the algorithm divides it by two, and if n is odd, the algorithm multiplies it by three and adds one. The algorithm repeats this, until n is one. For examp