Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
1.00/5 (4 votes)
See more:
5 10 15
15 20 25
20 25 30 35
25 30 35 40 45
Posted
Comments
Leo Chapiro 28-Sep-15 7:21am    
phil.o 28-Sep-15 7:22am    
What have you tried? Where are you stuck? No-one is going to do your homework for you.
deepankarbhatnagar 28-Sep-15 8:42am    
Where you struck, please show your code.
George Swan 28-Sep-15 12:11pm    
Here's a hint. Try analysing the pattern. It is made up of rows and columns. The number of columns in a row is equal to the row number, starting from row 1 at the top. The first column is the row number multiplied by 5, subsequent columns are equal to the previous column plus 5.
BillWoodruff 28-Sep-15 17:29pm    
You need to show us your current efforts to code a solution.

1 solution

This is not a question. It will probably be flagged before this solution is seen. In future, I will not volunteer a solution until you have asked the question.

You should know by now how to ask a question on these forums.

The implied query seems simple, though:

C#
public Enumerable<int> NumberPattern(int n){

  int baseNum = 5;
  
  for(int i = n; i < 2*n; i++){
    yield baseNum * i
  }

  // OR
  for (int i = 0; i < n; i++){
     yield baseNum * (n + i);
  }

  //OR
  int[] result = new int[n]{
  for (int i = 0; i < n; i++){
     result[i] = baseNum * (n + i);
  }
  return result;
}

</int>
 
Share this answer
 
v2
Comments
Maciej Los 28-Sep-15 8:10am    
//OR...
5ed!
Arasappan 28-Sep-15 9:23am    
hmm me to...
George Swan 28-Sep-15 12:17pm    
Does this output the pattern as illustrated in the question? 5,10,15,15,20,25,20,25 etc
Andy Lanng 28-Sep-15 12:24pm    
can't you tell?

No, it returns the sequence specified in the question for array length n. However the OP wants to use it is up to him but the number pattern is well represented
BillWoodruff 28-Sep-15 17:24pm    
My vote of #1. Your hunger to write code and look smart has overcome your ability to assess the situation "on the ground."

You are wasting your time providing a complex solution to a no-code-shown OP who is probably a beginner doing homework. Do you really think the OP is going to understand the complexity of the IEnumerable Iteration 'Yield operator ?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900