Posts

How to create math function that converts decimal number to binary format.

Image
Let's create a mathematical function that converts decimal to binary using the coding function of the function calculator . Copy the code below and paste it into the code window of the function calculator's factory page, click the run button to run the code, and click the save button to save the mathematical function. def toBinary(num) = toBinary((num−num%2)/2)*10+num%2; toBinary(0)=0; toBinary(1)=1; You can go back to the calculator page and press the F2 button to use the function you just created in your calculations as shown below. The above code is defined recursively. The result of the calculation is a decimal number consisting of 1 and 0, which looks like a binary number. In simple terms, the remainder of the given number divided by 2 is placed at the end of the number, and the binary quotient of the division by 2 is placed one digit higher than that. Convert binary to decimal This time we are going to create a math function that converts binary number to deci...

Programming D-Day Using Function Calculator

Image
Mastering D-Day Calculations with Function Calculator With  Function Calculator , users can create custom functions to solve complex problems, including date calculations. At the heart of this capability is the  now()  function , a built-in feature of the app that provides a precise 14-digit timestamp representing the current time. Using this powerful function, users can program their own logic to calculate D-Days (countdowns) and days between dates. In this guide, we’ll explore how you can use  now()  to program your own D-Day functions, complete with examples and practical use cases. Understanding the  now()  Function The  now()  function is a built-in function provided by  Function Calculator . It returns a  14-digit timestamp  in the format  YYYYMMDDHHMMSS , which represents the current date and time down to the second. This serves as the foundation for creating custom date-related calculations. For example: If  n...

Hanoi Tower - How many to move disks.

How to move disks in Hanoi tower : programming example Welcome to the blog post where we showcase the capabilities of our  Function Calculator  by solving one of the most famous problems in computer science and mathematics:  The Tower of Hanoi . This post will introduce how to program to solve hanoi problem. What is the Tower of Hanoi? The  Tower of Hanoi  is a mathematical puzzle consisting of three rods (pegs) and a number of disks of different sizes. The puzzle starts with all disks stacked on one rod in decreasing size, with the largest disk at the bottom. The objective is to move all disks from the source rod to the destination rod, following these rules: Only one disk can be moved at a time. A disk can only be placed on top of a larger disk or an empty rod. You must use an auxiliary rod to assist in moving the disks. Below is code examples that solve hanoi tower problem. You can copy below code and go to the Factory page in the Function Calculator and past...

How Deep Is the Well?

Image
How Deep Is the Well? Exploring Physics with Code Have you ever dropped a rock into a well and wondered how deep it is? The sound of the splash echoes back, but how can we calculate the depth without physically measuring it? Let’s dive into the fascinating world of physics and programming to solve this age-old question using Function Calculator.   The Science Behind It When you drop an object into a well, two key events occur: The Fall : The object falls under the influence of gravity, accelerating as it goes. The Sound : After hitting the water, the sound of the splash travels back up to you. By combining these two events, we can calculate the depth of the well using basic physics. The total time  t  (the time it takes for you to hear the splash) is a combination of: The time it takes for the object to fall (fallTime). The time it takes for the sound to travel back up ( soundTime ). Using these principles, we can derive a quadratic equation to calculate the depth. The Fo...

Mathematics Function Examples

def round6(value)=round(value*10^6)/10^6; def max(a,b){   if(a>=b){     return a;   }   else{     return b;   } } def min(a,b){   if(a<=b){     return a;   }   else{     return b;   } } def facorial(n)=n*factorial(n−1); factorial(0)=1; def fibonacci(n)=fibonacci(n−1)+fibonacci(n−2); fibonacci(1)=1; fibonacci(2)=1; def isPrime(n){   if(n<=1){     return false;   }   var i=2;   while(i*i<=n){     if(n%i==0){       return false;     }     i=i+1;   }   return true; } def nthPrime(n){   var count=0;   var num=2;   while(count<n){     if(isPrime(num)){       count=count+1;     }     if(count==n){       return num;     }     num=num+1;   }   return num−1; } def det2(a,b,c,d){   return a*d−b*c; } def solveX2(a...

Daily life math function examples

def afterDiscounted(price,discountRate) =price*(1−discountRate/100); def hexTessellate(w,h,s){   if(w<=0||h<=0||s<=0){     return 0;   }   var col=floor(w/(3/2*s));   var row=floor(h/(sqrt(3)*s));   return col*row; } def 정육각형타일갯수(가로,세로,타일한변길이)=hexTessellate(가로,세로,타일한변길이); def rhombusTessellate(w,h,s,θ){   if(w<=0||h<=0||s<=0||θ<=0||θ>=180){     return 0;   }   if(θ>90){     θ=180−θ;   }   var wr=s*(1+cos(θ));   var hr=s*sin(θ);   var col=floor(w/wr);   var row=floor(h/hr);   return col*row; } def penroseTileCount(w,h,s){   if(w<=0||h<=0||s<=0){     return 0;   }   var thinAngle=36;   var fatAngle=72;   var thinWidth=s/cos(thinAngle/2);   var thinHeight=s*sin(thinAngle);   var fatWidth=s/cos(fatAngle/2);   var fatHeight=s*sin(fatAngle);   var thinColCount=floor(w/thinWidth);   var thinRowCount=f...