Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // This code will generate the odds of a lottery win
- import java.util.Scanner;
- public class Task1 {
- public static void main(String[] args) {
- int fact = 1;
- long p = 1 ;
- int z = 1;
- int c = 1;
- Scanner input = new Scanner(System.in);
- int n = input.nextInt();
- int k = input.nextInt();
- input.close();
- for(int i = 1; i <= k; i ++)
- {
- p =(long) (p*(n - k + i));
- }
- System.out.println(p);
- while(z <= k)
- {
- fact = fact * z;
- z++;
- }
- System.out.println(fact);
- c = (int) (p / fact);
- System.out.println("The odds are:");
- System.out.println(c);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement