ACL4 - Editorial

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

  1. Loop from 1 to N.

  2. Check if the iterator is divisible by 5 or not .

  3. If it is not divisible by 5 print the pattern.

  4. If it is divisible then skip that line.

  5. Output the result from step 3.

For Example:

Let k = 12











TIME COMPLEXITY:

O(n(n+1)/2)