Ledger Nano X - The secure hardware wallet
SHARE
TWEET

Untitled

a guest Mar 31st, 2020 74 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class Main {
  2.     public static void main(String[] args) {
  3.         int num1;
  4.         int num2;
  5.         int result;
  6.        
  7.         Scanner entrada = new Scanner(System.in);
  8.         System.out.println("Digite os numeros para ser feita a soma recursivas");
  9.        
  10.         num1 = entrada.nextInt();
  11.         num2 = entrada.nextInt();
  12.        
  13.         if (num1 > 0 && num2 > 0){
  14.             result = somasRecursivas(num1, num2);
  15.             System.out.pintln(result);
  16.         }    
  17.     }
  18.  
  19.     public static int somasRecursivas(int num1, int num2) {
  20.         if (num2 == 0) {
  21.             return num2;
  22.         } else {
  23.             return num1 + somasRecursivas(num1, num2 - 1);
  24.         }
  25.     }
  26. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top