Advertisement
Guest User

Untitled

a guest
Dec 14th, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. import java.util.ArrayList;
  2. import java.util.Scanner;
  3.  
  4. public class Main {
  5.  
  6. public static void main(String[] args) {
  7.  
  8.  
  9. Scanner tamere = new Scanner(System.in);
  10. int rigoloNombre = tamere.nextInt();
  11.  
  12. int resultons = recurenceDuGhetto.testonsCa(rigoloNombre);
  13.  
  14.  
  15. System.out.println(resultons);
  16.  
  17. }
  18.  
  19.  
  20. }
  21.  
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46. public class recurenceDuGhetto {
  47.  
  48. public recurenceDuGhetto() {
  49.  
  50. }
  51.  
  52. public static int testonsCa(int n) {
  53. if (n == 0 || n == 1) {
  54. return 1;
  55. }
  56. if (n == 2)
  57. return 2;
  58. if (n == 3)
  59. return 5;
  60. else{
  61. int resultat = 1;
  62.  
  63. for (int i = 1; i < n; i++){
  64. int extra = (n - i) * testonsCa(i);
  65. resultat = resultat + extra;
  66. //System.out.println(i + " i bah il vaut et extra il vaut " + extra + " et enfin result " + resultat);
  67. }
  68. return resultat;
  69. }
  70.  
  71. }
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement