Advertisement
Guest User

Untitled

a guest
Nov 18th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. package newton;
  2.  
  3.  
  4. public class Newton {
  5.  
  6.  
  7. public static void main(String[] args) {
  8. System.out.println("Wynik to: " + wzorNewtona(4,3));
  9. }
  10.  
  11. static int wzorNewtona( int n, int k){
  12. int[][] tab = new int[n+1][k+1];
  13. for (n = 0; n < tab.length; n++) {
  14. for (k = 0; k < tab[n].length; k++) {
  15. if( n==k || k==0 ){
  16. tab[n][k] = 1;
  17. }
  18.  
  19. if( k>0 && k<n ){
  20. tab[n][k] = tab[n-1][k]+tab[n-1][k-1];
  21. }
  22. System.out.print(tab[n][k]+"\t");
  23. }
  24. System.out.print("\n");
  25. }
  26. return tab[n-1][k-1];
  27. }
  28.  
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement