Write a program to display the mathematical table for a given number for 10 iterations
in the given format:
Table of 5
5 * 1 = 5
5 * 2 = 10
…
5 * 10 = 50
The number has to be taken as input from the user
Answers
Answer:
coins = [1,5,10,25]
d = {}
# stores tuples of the form
(
# of coins, [coin list])
# finds the minimum
# of coins needed to
# make change for some number of cents def m(cents):
if cents in d.keys(): return d[cents] elif cents > 0: choices
= [(m(cents - x)[0] + 1, m(cents - x)[1] + [x]) for x in coins if cents >= x]
# given a list of tuples, python's min function
# uses the first element of each tuple for comparison d[cents]
= min(choices) return d[cents] else: d[0] =
(0, []) return d[0] for x in range(1, 100): val = m(x) print x,
"cents requires", val[0], "coins:", val[1]
punineep and 7 more users found this answer helpful
THANKS
5
3.0
(2 votes)
1
justauser2 avatar
i need java program
Log in to add comment
Answer
4.2/5
15
Prathamesh1856
Virtuoso
77 answers
8.6K people helped
Heya There
Here is Your To The Question
import java.util.Scanner;
class MultiplicationTable {
public static void main(String args[]) {
int n, c; System.out.println("Enter an integer to print it's multiplication table");
Scanner in = new Scanner(System.in);
n = in.nextInt();
System.out.println("Multiplication table of "+n+" is :-");
for ( c = 1 ; c <= 10 ; c++ ) System.out.println(n+"*"+c+" = "+(n*c)); } }