Pattern programs are nothing but patterns consisting of numbers, alphabets or symbols in a particular form. These kinds of pattern programs can be solved easily using for loop condition. Program 1:- Output Screenshot:- Program 2:- Output Screenshot:- Program 3:- Output Screenshot:- Program 4:- Output Screenshot:- Program 5:- Output Screenshot:-
Category Archives: Uncategorized
Fibonacci
Fibonacci Sequence = 0, 1, 1, 2, 3, 5, 8, 13, 21, …. “3” is obtained by adding the third and fourth term (1+2) and so on. For example, the next term after 21 can be found by adding 13 and 21. Therefore, the next term in the sequence is 34. Program:- Output Screenshot:-
LCM in For loop
LCM stands for least common multiple. The least common multiple of two numbers is the smallest number that is a multiple of both of them. Program:- Output Screenshot:-
Find big from leas common multiple
Program:- Output Screenshot:-
Find the Divisor of Number
Program:- Output Screenshot:-
For loop
A “For” Loop is used to repeat a specific block of code a known number of times. For example, if we want to check the grade of every student in the class, we loop from 1 to that number. When the number of times is not known before hand, we use a “While” loop. InitiateContinue reading “For loop”
Perfect Number
perfect number, a positive integer that is equal to the sum of its proper divisors. The smallest perfect number is 6, which is the sum of 1, 2, and 3. Other perfect numbers are 28, 496, and 8,128. Program:- Output Screenshot:-
Strong Number
Strong number is a number whose sum of all digits’ factorial is equal to the number ‘n’. Factorial implies when we find the product of all the numbers below that number including that number and is denoted by ! (Exclamation sign), For example: 4! = 4x3x2x1 = 24. Program:- Output Screenshot:-
Neon Number
A neon number is a number where the sum of digits of the square of the number is equal to the number. Let’s take an example. n = 9. square = 81. sum of digits of square = 8 + 1 = 9. Program:- Output Screenshot:-
Amstrong Number
In case of an Armstrong number of 3 digits, the sum of cubes of each digit is equal to the number itself. For example: 153 = 1*1*1 + 5*5*5 + 3*3*3 // 153 is an Armstrong number. Program:- Output Screenshot:-