1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
pub mod Calculator_functions{ pub mod basic_function{ pub fn add(x:u32,y:u32)->u32{ x+y } pub fn sub(x:u32,y:u32) ->u32{ x-y } pub fn divide(x:u32 , y:u32)->u32{ x/y } pub fn multiply(x:u32 , y:u32)->u32{ x*y } } pub mod Power_functions{ pub fn square(x:u32) -> u32{ x*x } pub fn cube(x:u32) -> u32{ x*x*x } pub fn power(x:u32,y:u32) -> u32{ let mut ans = x; for i in 1..y{ ans = ans*x; } ans } } }