Axeer

??????

Nov 30th, 2021
939
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. fn digital_root(n: i64) -> i64 {
  2.     println!("{}", n);
  3.     let sum = n.to_string().into_bytes();
  4.     if n.to_string().len() == 2 {
  5.         let x1 = (sum[0]-48) as i64;
  6.         let x2 = (sum[1]-48) as i64;
  7.         return x1+x2;
  8.     }
  9.     else{
  10.         let mut x:i64 = 0;
  11.         for i in 0..n.to_string().len() {
  12.             x += (sum[i] - 48) as i64;
  13.         }
  14.         return digital_root(x);
  15.     }
  16. }
  17.  
  18. fn main(){
  19.     let x = digital_root(132186738569);
  20.     println!("{}", x);
  21. }
  22.  
RAW Paste Data