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 TypeScript

2 Answers

0 votes
// Generic Root of a number = sum of all the digits of the number until we get a single-digit
// 12345 : 1 + 2 + 3 + 4 + 5 = 15 : 1 + 5 = 6
// Generic Root of 12345 is 6

   
const num: number = 12345;
  
const generic_root: number = 1 + ((num - 1) % 9);
 
console.log("generic root = " + generic_root);
  
  
  
  
/*
run:
     
"generic root = 6"
     
*/
   

 



answered Oct 28, 2021 by avibootz
0 votes
// Generic Root of a number = sum of all the digits of the number until we get a single-digit
// 12345 : 1 + 2 + 3 + 4 + 5 = 15 : 1 + 5 = 6
// Generic Root of 12345 is 6
   
const num: number = 12345;
  
let generic_root: number;
  
(generic_root = num % 9) ? num : 9;
 
console.log("generic root = " + generic_root);
  
  
  
  
/*
run:
     
"generic root = 6" 
     
*/

 



answered Oct 28, 2021 by avibootz

Related questions

1 answer 166 views
2 answers 167 views
2 answers 149 views
2 answers 335 views
2 answers 204 views
3 answers 161 views
3 answers 194 views
...