Felanpro

uppgift86

Nov 19th, 2020
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. package skola;
  7. import java.util.Scanner;
  8.  
  9. /**
  10. *
  11. * @author Felix 1
  12. */
  13. public class Uppgift86 {
  14.  
  15. /**
  16. * @param args the command line arguments
  17. */
  18. public static void main(String[] args) {
  19. Scanner inmatning = new Scanner(System.in);
  20. System.out.print("n: ");
  21. int n = inmatning.nextInt();
  22. int summa = 1;
  23. for(int i = 1; i <= n; i++)
  24. {
  25. summa *= i;
  26. if(i == n)
  27. {
  28. System.out.print(i + " = " + summa);
  29. }
  30. else
  31. System.out.print(i + " * ");
  32. }
  33. }
  34.  
  35. }
  36.  
Add Comment
Please, Sign In to add comment