#!/usr/bin/env python # coding: utf-8 # https://bermatematika.net/2016/10/29/perkalian-pecahan-yang-menarik/ # In[1]: from __future__ import division # In[2]: a = range(0, 10) b = range(0, 10) c = range(0, 10) d = range(0, 10) # In[3]: print a # In[4]: count = 0 for ai in a: for bi in b: for ci in c: for di in d: if ai == 0 or bi == 0 or ci == 0 or di == 0: continue; else: x = ai*ci y = bi*di res = x/y xx = ai*10 + ci yy = bi*10 + di res2 = xx/yy if res == res2: count += 1 print str(count)+'. (', ai, '/', bi, ') x (', ci, '/', di, ') = ' , res, ' = ', xx, '/', yy # In[ ]: