series 1,2,3,4,5,4,3,2,1,2,3,4,5,4,3,2,1

  • Thread starter Thread starter HARSHAWARDHAN. S .SHASTRI
  • Start date Start date
H

HARSHAWARDHAN. S .SHASTRI

I am looking for code which can generate following series.

1
2
3
4
5
4
3
2
1
2
3
4
5
4
3
2
1
Pl help.

H S Shastri
 
HARSHAWARDHAN. S .SHASTRI said:
I am looking for code which can generate following series.

1
2
3
4
5
4
3
2
1
2
3
4
5
4
3
2
1


Strange!?

Debug.Print 1
For k = 0 To 99
Debug.Print 2 + (k Mod 8) _
- (2 * ((k Mod 8) \ 4) * (((2 * k) Mod 8) \ 2 + 1))
Next k
 
Linq said:
Strange!? indeed!

I can't imagine a real-world application, hence my question!


Maybe it's an translated, integer version of a sine wave
;-)
 
HARSHAWARDHAN. S .SHASTRI said:
I am looking for code which can generate following series.

vstep = 1
vout = 1
For k = 1 To 99
For j = 1 To 4
Debug.Print vout
vout = vout + vstep
Next
vstep = vstep * -1
Next

or ....

Dim a As Variant
a = Array(1, 2, 3, 4, 5, 4, 3, 2)
For k = 1 To 99
For i = 0 To 7
Debug.Print a(i)
Next
Next
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top