Simplify fractions

Hi, I want to add a feature to my application that can simplify fractions, for example the user enters a fraction (2, a face, a denominator) and the device simplifies the fraction for that. Example 4
_
6 is 2
_
3 Please help me thank you

You need to find GCD - greatest common divisor of numerator and denominator. Then devide both of them with GCD in order to simplify fraction

1 Like

Excuse me, what is gcd?

:point_up_2: :point_up_2:

1 Like

Please tell me how to find it


gcd_test

See the Euclidean Algorithm at

2 Likes

Thank you very much. Just one thing. Now how to convert this fraction to a decimal number, like 2-10, 0.2, please do not delete.

There is a block for that.

I forget the name. (Format as decimal?)

Look in the math blocks section.

To convert a fraction into a decimal like 2/10, simply do the division 2 ÷ 10.

3 Likes

Honestly, I mean the opposite, that is, the user enters 0.5, for example. The answer is that it should be a simple fraction, which is here 1_2 Please help me

This is what you asked, but since you want the opposite, I'll try my best.

However, have you tried these?

A very good way to learn App Inventor is to read the free Inventor’s Manual here in the AI2 free online eBook http://www.appinventor.org/book2 - the links are at the bottom of the Web page. The book ‘teaches’ users how to program with AI2 blocks.

There is a free programming course here http://www.appinventor.org/content/CourseInABox/Intro and the aia files for the projects in the book are here: http://www.appinventor.org/bookFiles.

How to do a lot of basic things with App Inventor are described here: http://www.appinventor.org/content/howDoYou/eventHandling.

Also do the tutorials at http://appinventor.mit.edu.ezproxy.canberra.edu.au/explore/ai2/tutorials.html to learn the basics of App Inventor, then try something and follow the Top 5 Tips: How to learn App Inventor 2.

You posted 14 topics about how to do things with MIT App Inventor. I understand that you need help, but have you tried to learn MIT App Inventor yourself?

App Inventor is like fishing. You can't tell us to fish for you just because you don't have time always- you must learn to fish in order to get your fish.

I'm sorry I did not understand what you mean because I use a translator. Do you mean that you have seen the relevant books? No, because I do not have enough time, please help me

Yes. Have you searched on Google, YouTube or in the MIT App Inventor Library for answers?

I mean guidance on whether it is possible to convert decimals to fractions

Ok, I'll try.

com.gordonlu.decimal2fraction.aix (6.0 KB)

image

Try this extension.

image

If somebody post a method with this with built-in blocks, I'll be glad.

1 Like

It worked great just one more thing how to put the denominator in a separate text and the face in a separate text

Can you give me a demo? I don't understand.

For example, instead of writing 12/2 in the answer, I want to put 12 in a text and 2 in a separate text.

Updated the blocks per your request.

com.gordonlu.decimal2fraction.aix (6.4 KB)

2 Likes

Thank you..... :grinning: :heart_eyes: :heart_eyes: :heart_eyes: :kissing_heart: :kissing_heart: :kissing_heart: :kissing_heart:

1 Like