DIFFICULTY:
Easy
PREREQUISITES:
Pattern
PROBLEM:
Print Pattern of N line using “" with having 'i’th line having "” equal to the ‘i’ in it and if is divisible 5 then skip that line.
QUICK EXPLANATION:
Loop from i=1 to N and if i is not divisible from 5 then print the “*” ,‘i’ times in that line else skip that line.
EXPLANATION:
The approach can be to start a loop from 1 until we reach the N and check if the iterator is divisible by 5 or not .If it not divisible print “*” iterator times else don’t print anything in that line
-
Loop from 1 to N.
-
Check if the iterator is divisible by 5 or not .
-
If it is not divisible by 5 print the pattern.
-
If it is divisible then skip that line.
-
Output the result from step 3.
For Example:
Let k = 12
TIME COMPLEXITY:
O(n(n+1)/2)