Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,845 questions

51,766 answers

573 users

How to calculate the series 1 2 3 6 9 18 27 54 81 162 243 ... N in VB.NET

2 Answers

0 votes
' 1 2 3 6 9 18 27 54 81 162 243 ... N 
   
' (1) (2) 1 * 3 (3) 2 * 3 (6) : 3 * 3 (9) 6 * 3 (18) :
' 9 * 3 (27) 18 * 3 (54) : 27 * 3 (81) 54 * 3 (162) :
' 81 * 3 (243)

Imports System

Public Class Program
	Public Shared Sub Main()
        Dim a As Integer = 1, b As Integer = 2, total As Integer = 11
		
        Console.Write("{0} {1} ", a, b)

        For i As Integer = 3 To total
            If i Mod 2 = 1 Then
                a = a * 3
                Console.Write("{0} ", a)
            Else
                b = b * 3
                Console.Write("{0} ", b)
            End If
        Next
	
    End Sub
End Class



' run:
'
' 1 2 3 6 9 18 27 54 81 162 243
'

 



answered Mar 30, 2022 by avibootz
0 votes
' 1 2 3 6 9 18 27 54 81 162 243 ... N 
  
' (1) 1 + 1 (2) : 1 + 2 (3) : 3 + 3 (6) : 3 + 6 (9) :
' 9 + 9 (18) : 9 + 18 (27) : 27 + 27 (54) : 27 + 54 (81) :
' 81 + 81 (162) : 81 + 162 (243)

Imports System

Public Class Program
	Public Shared Sub Main()
        Dim a As Integer = 1, b As Integer = 0, total As Integer = 11

        For i As Integer = 1 To total
            If i Mod 2 = 1 Then
                b = a + a
                Console.Write("{0} ", a)
            Else
                a = a + b
                Console.Write("{0} ", b)
            End If
        Next
	
    End Sub
End Class





' run:
'
' 1 2 3 6 9 18 27 54 81 162 243
'

 



answered Mar 30, 2022 by avibootz

Related questions

1 answer 179 views
2 answers 214 views
2 answers 206 views
2 answers 201 views
2 answers 264 views
...