Posts

Showing posts from September, 2025

🛍️ How to Quickly Calculate Discounted Price with Function Calculator

Image
Have you ever stood in a store thinking: “This item is 30% off… but how much will it actually cost?” Instead of pulling out a normal calculator and pressing buttons again and again, Function Calculator lets you create your own function for this. Once you make it, you can reuse it anytime with just one line. ✨ The Function Here’s a simple function for discount calculation: def discount(price, percent) = price * (100 - percent) / 100; Copy above code in the Factory page and press run button to implement code and press save button to save the function for later use. Here   price = original price percent = discount percentage 💡 Example Usage Imagine a jacket that costs 50 dollars and it’s on 30% sale. Just type: discount(50, 30) ➡️ The result will be: 35 So you’ll pay 35 dollars instead of 50. 🎯 Why It’s Useful No need to re-think formulas every time. Works for any discount rate, not just 30%. You can even combine it with tax calculation if yo...

What Day Will It Be in 100 Days?

Image
What Day Will It Be in 100 Days? Do you want to know what date and day it will be after 10, 50, or even 100 days? With Function Calculator, you can calculate it yourself — no Google needed. 🚀 1. Today’s Date: now() The built-in function now() gives today’s date and time as a 14-digit number. Example: 20250921130330 This means: Year = 2025 Month = 09 Day = 21 Hour =13 Minute = 03 Second = 30 2. Days in Each Month (with Switch) Since our script has no lists, we use switch statements to handle month lengths. ( Copy below code and go to the Factory page in the calculator and paste it. Press run button to implement code and press save button to save your function .) def getDaysInMonth(year, month) {     if (month==1) {          return 31;     } else if (month==2) {          if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0) {             return 29;         ...

Math function to calculate age.

Image
How to Create an Age Calculator Function in Function Calculator One practical function you can create in Function Calculator is an age calculator. With just a few lines of code, you can calculate a person’s age from their birth year. Step 1 : Understand the now() function In Function Calculator, the built-in function now() returns the current date and time as a 14-digit integer in the format: YYYYMMDDHHMMSS For example: 20250915162430 represents 2025-09-15 16:24:30 (4:24:30 pm). Step 2 : Extract the current year Since the first four digits represent the year, we can isolate them by dividing the number by 10^10 and applying floor(). def year() {     var date = now();     return floor(date / 10^10); } This function takes the 14-digit number from now(), removes the last 10 digits (month, day, time), and leaves only the year. For example: floor(20250915162430 / 10^10) = 2025 Step 3 : Create the age function Now, we can calculate age by subtracting the birth ...