How can I show mathematically the time complexity of this function is O(N)? int foo(N){
   if(N &lt;= 1){
       return 0
   }else{
       return 1 + foo(N-1)
   }
}

I can tell that the time complexity of this program is O(N) but I am unsure on how to prove it mathematically? If I can get some hints I'd grealy appreciate it.
You can use induction on input.
For example, in your foo,
to show that foo(N) uses exactly N comparisons,
Base case: foo(1) uses 1 comparison
Induction hypothesis: foo(N) uses N comparisons
Step case: foo(N+1) does one comparison and then call foo(N), thus in total, does N+1 comparisons.
You can prove similar statement for addition or all operations, and then you can give a time complexity based on those number of operations.