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,914 questions

51,847 answers

573 users

How to calculate generic root of a number in VB.NET

2 Answers

0 votes
Imports System
Imports Microsoft.VisualBasic

Public Class Program
	Public Shared Sub Main()
        Dim remainder As Long, num As Long = 12345, sum As Long = 0

        While num > 10
            sum = 0
            Console.Write("sum digits of {0} = ", num)

            While num <> 0
                remainder = num Mod 10
                num = num \ 10 ' \ not /
                sum += remainder
            End While

            Console.Write("{0}" & vbLf, sum)

            If sum > 10 Then
                num = sum
            Else
                Exit While
            End If
        End While

        Console.Write("generic root = {0}", sum)
    End Sub
End Class
	
	
	
	
' run:
'
' sum digits of 12345 = 15
' sum digits of 15 = 6
' generic root = 6
'
	

 



answered Oct 10, 2021 by avibootz
0 votes
Imports System

Public Class Program
	Public Shared Sub Main()
        Dim num As Long = 12345
		
        Dim generic_root As Long = 1 + ((num - 1) Mod 9)
		
        Console.Write("generic root = {0}", generic_root)
    End Sub
End Class
	
	
	
	
' run:
'
' generic root = 6
'

 



answered Oct 10, 2021 by avibootz

Related questions

1 answer 166 views
2 answers 146 views
2 answers 149 views
2 answers 335 views
2 answers 204 views
3 answers 161 views
3 answers 195 views
...