(n: i32)
| 1 | pub fn clumsy(n: i32) -> i32 { |
| 2 | if n == 1 { return 1 } |
| 3 | if n == 2 { return 2 } |
| 4 | let mut ret = n * (n-1) / (n-2) + n-3; |
| 5 | let mut tmp = 0; |
| 6 | for (i, num) in (1..=n-4).rev().enumerate() { |
| 7 | match i % 4 { |
| 8 | 0 => { tmp = num }, |
| 9 | 1 => { tmp *= num }, |
| 10 | 2 => { |
| 11 | ret -= (tmp as f64 / num as f64).floor() as i32; |
| 12 | tmp = 0 |
| 13 | }, |
| 14 | 3 => { ret += num }, |
| 15 | _ => { }, |
| 16 | } |
| 17 | } |
| 18 | ret - tmp |
| 19 | } |
| 20 | |
| 21 | fn main() { |
| 22 | println!("{:?}", clumsy(2)); |
nothing calls this directly
no outgoing calls
no test coverage detected