Viniciusfelbs

A Dúvida de Mike

Sep 24th, 2019
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.59 KB | None | 0 0
  1.  
  2. import java.util.Scanner;
  3.  
  4. public class HuxleyCode {
  5.  
  6.     public static double p(int x, int y) {
  7.          if(y==1){
  8.              return x;
  9.          }else{
  10.            return x+p(x,y-1);
  11.          }
  12.     }
  13.  
  14.     public static void main(String args[]) {
  15.         Scanner s = new Scanner(System.in);
  16.         int QuantCorda = s.nextInt();
  17.         int QuantMoeda = s.nextInt();
  18.         int CustoCorda = s.nextInt();
  19.         if(p(QuantCorda,CustoCorda)>=CustoCorda){
  20.             System.out.print("Sim");
  21.         }else{
  22.             System.out.print("Não");
  23.         }
  24.        
  25.  
  26.     }
  27. }
Add Comment
Please, Sign In to add comment