Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to multiply?

Status
Not open for further replies.

Cantona7

MIS
Joined
Apr 29, 2003
Messages
4
Location
US
i have to list of number and i need to multiply them and insert the result to another list- every atom in the list must be a single digit, and the numbers r in reversed order.
exmple
123*456=56088
list1-3,2,1 list2 - 6,5,4 result 8,8,0,6,5
thanks
 
This program reverse the given number.

rev(N, [N]) :- N < 10, !.
rev(N, [VH|VR]) :- VH is N mod 10, N2 is N // 10, rev(N2, VR).

?- rev(0, Ans).
Ans = [0] ;

?- rev(123, Ans).
Ans = [3,2,1] ;

?- rev(65535, Ans).
Ans = [5,3,5,5,6] ;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top