codeparrot/xlcost-text-to-code huggingface dataset:
Area of plot remaining at the end | Function to return the area of the remaining plot ; Continue while plot has positive area and there are persons left ; If length > breadth then subtract breadth from length ; Else subtract length from breadth ; Driver code
function remainingArea ( N , M , K ) { while ( K -- && N && M ) { if ( N > M ) N = N - M ; else M = M - N ; } if ( N > 0 && M > 0 ) return N * M ; else return 0 ; } var N = 5 , M = 3 , K = 2 ; document . write ( remainingArea ( N , M , K ) ) ;
Length of the direct common tangent between two externally touching circles | Function to find the length of the direct common tangent ; Driver code
function lengtang ( r1 , r2 ) { document . write ( " " + " " + ( 2 * Math . sqrt ( r1 * r2 ) ) . toFixed ( 5 ) ) ; } var r1 = 5 , r2 = 9 ; lengtang ( r1 , r2 ) ;
Shortest distance between a point and a circle | Function to find the shortest distance ; Driver code
function dist ( x1 , y1 , x2 , y2 , r ) { document . write ( " " + " " + ( Math . sqrt ( ( Math . pow ( ( x2 - x1 ) , 2 ) ) + ( Math . pow ( ( y2 - y1 ) , 2 ) ) ) - r ) . toFixed ( 5 ) ) ; } var x1 = 4 , y1 = 6 , x2 = 35 , y2 = 42 , r = 5 ; dist ( x1 , y1 , x2 , y2 , r ) ;
Distance between two parallel lines | Function to find the distance between parallel lines ; Driver Code
function dist ( m , b1 , b2 ) { var d = Math . abs ( b2 - b1 ) / ( ( m * m ) - 1 ) ; return d ; } var m = 2 , b1 = 4 , b2 = 3 ; document . write ( dist ( m , b1 , b2 ) . toFixed ( 5 ) ) ;
Length of the normal from origin on a straight line whose intercepts are given | Function to find the normal of the straight line ; Length of the normal ; Driver code
function normal ( m , n ) { var N = ( ( Math . abs ( m ) * Math . abs ( n ) ) / Math . sqrt ( ( Math . abs ( m ) * Math . abs ( m ) ) + ( Math . abs ( n ) * Math . abs ( n ) ) ) ) ; return N ; } var m = - 5 , n = 3 ; document . write ( normal ( m , n ) . toFixed ( 5 ) ) ;
Check if it is possible to create a polygon with given n sides | Function that returns true if it is possible to form a polygon with the given sides ; Sum stores the sum of all the sides and maxS stores the length of the largest side ; If the length of the largest side is less than the sum of the other remaining sides ; Driver Code
function isPossible ( a , n ) { let sum = 0 , maxS = 0 ; for ( let i = 0 ; i < n ; i ++ ) { sum += a [ i ] ; maxS = Math . max ( a [ i ] , maxS ) ; } if ( ( sum - maxS ) > maxS ) return true ; return false ; } let a = [ 2 , 3 , 4 ] ; let n = a . length ; if ( isPossible ( a , n ) ) document . write ( " " ) ; else document . write ( " " ) ;
Find the area of the shaded region formed by the intersection of four semicircles in a square | Function to return the area of the shaded region ; Area of the square ; Area of the semicircle ; There are 4 semicircles shadedArea = Area of 4 semicircles - Area of square ; driver code
function findAreaShaded ( a ) { let sqArea = a * a ; let semiCircleArea = ( 3.14 * ( a * a ) / 8 ) ; let ShadedArea = 4 * semiCircleArea - sqArea ; return ShadedArea ; } let a = 10 ; document . write ( findAreaShaded ( a ) ) ;
Number of steps required to reach point ( x , y ) from ( 0 , 0 ) using zig | Function to return the required position ; Driver Code
function countSteps ( x , y ) { if ( x < y ) { return x + y + 2 * parseInt ( ( y - x ) / 2 ) ; } else { return x + y + 2 * parseInt ( ( ( x - y ) + 1 ) / 2 ) ; } } var x = 4 , y = 3 ; document . write ( countSteps ( x , y ) ) ;
Find whether only two parallel lines contain all coordinates points or not | Find if slope is good with only two intercept ; if set of lines have only two distinct intercept ; Function to check if required solution exist ; check the result by processing the slope by starting three points ; Driver code
function isSlopeGood ( slope , arr , n ) { var setOfLines = new Set ( ) ; for ( var i = 0 ; i < n ; i ++ ) setOfLines . add ( arr [ i ] - slope * ( i ) ) ; return setOfLines . size == 2 ; } function checkForParallel ( arr , n ) { var slope1 = isSlopeGood ( arr [ 1 ] - arr [ 0 ] , arr , n ) ; var slope2 = isSlopeGood ( arr [ 2 ] - arr [ 1 ] , arr , n ) ; var slope3 = isSlopeGood ( parseInt ( ( arr [ 2 ] - arr [ 0 ] ) / 2 ) , arr , n ) ; if ( slope1 slope2 slope3 ) { return 1 ; } return 0 ; } var arr = [ 1 , 6 , 3 , 8 , 5 ] ; var n = arr . length ; document . write ( checkForParallel ( arr , n ) ) ;
Check whether the point ( x , y ) lies on a given line | Function that return true if the given point lies on the given line ; If ( x , y ) satisfies the equation of the line ; Driver code
function pointIsOnLine ( m , c , x , y ) { if ( y == ( ( m * x ) + c ) ) return true ; return false ; } var m = 3 , c = 2 ; var x = 1 , y = 5 ; if ( pointIsOnLine ( m , c , x , y ) ) document . write ( " " ) ; else document . write ( " " ) ;
Find the coordinates of the fourth vertex of a rectangle with given 3 vertices | Function that return the coordinates of the fourth vertex of the rectangle ; Save the coordinates of the given vertices of the rectangle ; 1 - based indexing ; Driver code
function findFourthVertex ( n , m , s ) { var row = new Map ( ) , col = new Map ( ) ; for ( var i = 0 ; i < n ; i ++ ) for ( var j = 0 ; j < m ; j ++ ) if ( s [ i ] [ j ] == ' ' ) { if ( row . has ( i ) ) row . set ( i , row . get ( i ) + 1 ) else row . set ( i , 1 ) if ( col . has ( j ) ) col . set ( j , col . get ( j ) + 1 ) else col . set ( j , 1 ) } var x , y ; row . forEach ( ( value , key ) => { if ( value == 1 ) x = key ; } ) ; col . forEach ( ( value , key ) => { if ( value == 1 ) y = key ; } ) ; return [ x + 1 , y + 1 ] ; } var s = [ " " , " " , " " ] ; var n = s . length ; var m = s [ 0 ] . length ; var rs = findFourthVertex ( n , m , s ) ; document . write ( rs [ 0 ] + " " + rs [ 1 ] ) ;
Biggest Reuleaux Triangle inscribed within a square which is inscribed within an ellipse | Function to find the biggest reuleaux triangle ; length of the axes cannot be negative ; height of the reuleaux triangle ; area of the reuleaux triangle ; Driver code
function Area ( a , b ) { if ( a < 0 && b < 0 ) return - 1 ; let h = Math . sqrt ( ( ( Math . pow ( a , 2 ) + Math . pow ( b , 2 ) ) / ( Math . pow ( a , 2 ) * Math . pow ( b , 2 ) ) ) ) ; let A = 0.70477 * Math . pow ( h , 2 ) ; return A ; } let a = 5 , b = 4 ; document . write ( Area ( a , b ) + " " ) ;
Maximum given sized rectangles that can be cut out of a sheet of paper | Function to return the maximum rectangles possible ; Cut rectangles horizontally if possible ; One rectangle is a single cell ; Total rectangles = total cells ; Cut rectangles vertically if possible ; Return the maximum possible rectangles ; Driver Code
function maxRectangles ( L , B , l , b ) { var horizontal = 0 , vertical = 0 ; if ( l <= L && b <= B ) { var columns = parseInt ( B / b ) ; var rows = parseInt ( L / l ) ; horizontal = rows * columns ; } if ( l <= B && b <= L ) { var columns = parseInt ( L / b ) ; var rows = parseInt ( B / l ) ; vertical = rows * columns ; } return Math . max ( horizontal , vertical ) ; } var L = 10 , B = 7 , l = 4 , b = 3 ; document . write ( maxRectangles ( L , B , l , b ) ) ;
Largest right circular cone that can be inscribed within a sphere which is inscribed within a cube | Function to find the biggest right circular cone ; side cannot be negative ; radius of right circular cone ; height of right circular cone ; volume of right circular cone ; Driver code
function cone ( a ) { if ( a < 0 ) return - 1 ; var r = ( a * Math . sqrt ( 2 ) ) / 3 ; var h = ( 2 * a ) / 3 ; var V = ( 3.14 * Math . pow ( r , 2 ) * h ) ; return V ; } var a = 5 ; document . write ( cone ( a ) . toFixed ( 5 ) ) ;
Biggest Reuleaux Triangle inscribed within a square which is inscribed within a hexagon | Function to find the biggest reuleaux triangle ; side cannot be negative ; height of the reuleaux triangle ; area of the reuleaux triangle ; Driver code
function Area ( a ) { if ( a < 0 ) return - 1 ; let h = 1.268 * a ; let A = 0.70477 * Math . pow ( h , 2 ) ; return A ; } let a = 5 ; document . write ( Area ( a ) + " " ) ;
Biggest Reuleaux Triangle inscirbed within a square inscribed in a semicircle | Function to find the biggest reuleaux triangle ; radius cannot be negative ; height of the reuleaux triangle ; area of the reuleaux triangle ; Driver code
function Area ( r ) { if ( r < 0 ) return - 1 ; var x = ( 2 * r ) / ( Math . sqrt ( 5 ) ) ; var A = 0.70477 * ( Math . pow ( x , 2 ) ) ; return A ; } var r = 5 ; document . write ( Area ( r ) . toFixed ( 4 ) ) ;
Biggest Reuleaux Triangle inscribed within a Square inscribed in an equilateral triangle | Function to find the biggest reuleaux triangle ; side cannot be negative ; height of the reuleaux triangle ; area of the reuleaux triangle ; Driver code
function Area ( a ) { if ( a < 0 ) return - 1 ; let x = 0.464 * a ; let A = 0.70477 * Math . pow ( x , 2 ) ; return A ; } let a = 5 ; document . write ( Area ( a ) . toFixed ( 5 ) ) ;
Program for Area Of Square after N | Function to calculate area of square after given number of folds ; Driver Code
function areaSquare ( side , fold ) { var area = side * side ; return ( area * 1.0 ) / ( Math . pow ( 2 , fold ) ) ; } var side = 4 , fold = 2 ; document . write ( areaSquare ( side , fold ) ) ;
Biggest Reuleaux Triangle within a Square which is inscribed within a Circle | Function to find the Area of the Reuleaux triangle ; radius cannot be negative ; Area of the Reuleaux triangle ; Driver code
function ReuleauxArea ( r ) { if ( r < 0 ) return - 1 ; var A = 0.70477 * 2 * Math . pow ( r , 2 ) ; return A ; } var r = 6 ; document . write ( ReuleauxArea ( r ) ) ;
Largest right circular cylinder that can be inscribed within a cone which is in turn inscribed within a cube | Function to find the biggest right circular cylinder ; side cannot be negative ; radius of right circular cylinder ; height of right circular cylinder ; volume of right circular cylinder ; Driver code
function cyl ( a ) { if ( a < 0 ) return - 1 ; var r = ( 2 * a * ( Math . sqrt ( 2 ) ) / 3 ) ; var h = ( 2 * a ) / 3 ; var V = ( 3.14 * ( Math . pow ( r , 2 ) * h ) ) ; return V ; } var a = 5 ; document . write ( cyl ( a ) . toFixed ( 5 ) ) ;
Biggest Reuleaux Triangle within a Square which is inscribed within a Right angle Triangle | Function to find the biggest reuleaux triangle ; the height or base or hypotenuse cannot be negative ; height of the reuleaux triangle ; area of the reuleaux triangle ; Driver code
function Area ( l , b , h ) { if ( l < 0 b < 0 h < 0 ) return - 1 ; let x = ( l * b ) / ( l + b ) ; let A = 0.70477 * Math . pow ( x , 2 ) ; return A ; } let l = 5 , b = 12 , h = 13 ; document . write ( Area ( l , b , h ) . toFixed ( 5 ) ) ;
Largest square that can be inscribed within a hexagon which is inscribed within an equilateral triangle | Function to find the side of the square ; Side cannot be negative ; side of the square ; Driver code
function squareSide ( a ) { if ( a < 0 ) return - 1 ; var x = ( 0.423 * a ) ; return x ; } var a = 8 ; document . write ( squareSide ( a ) ) ;
Check if it is possible to draw a straight line with the given direction cosines | Function that returns true if a straight line is possible ; Driver code
function isPossible ( x , y , z ) { let a = Math . round ( x * x + y * y + z * z ) ; if ( Math . ceil ( a ) == 1 && Math . floor ( a ) == 1 ) return true ; return false ; } let l = 0.70710678 , m = 0.5 , n = 0.5 ; if ( isPossible ( l , m , n ) ) document . write ( " " ) ; else document . write ( " " ) ;
Length of Diagonal of a n | Function to find the diagonal of a regular polygon ; Side and side length cannot be negative ; diagonal degree converted to radians ; Driver code
function polydiagonal ( n , a ) { if ( a < 0 && n < 0 ) { return - 1 ; } return ( 2 * a * Math . sin ( ( ( ( n - 2 ) * 180 ) / ( 2 * n ) ) * 3.14159 / 180 ) ) ; } var a = 9 , n = 10 ; document . write ( polydiagonal ( n , a ) . toFixed ( 3 ) ) ;
Diagonal of a Regular Decagon | Function to return the diagonal of a regular decdiagonal ; side cannot be negative ; length of the diagonal ; Driver code
function decdiagonal ( a ) { if ( a < 0 ) return - 1 ; var d = 1.902 * a ; return d ; } var a = 9 ; document . write ( decdiagonal ( a ) ) ;
Diagonal of a Regular Heptagon | Function to return the diagonal of a regular heptagon ; side cannot be negative ; length of the diagonal ; Driver code
function heptdiagonal ( a ) { if ( a < 0 ) return - 1 ; var d = 1.802 * a ; return d ; } var a = 6 ; document . write ( heptdiagonal ( a ) . toFixed ( 5 ) ) ;
Diagonal of a Regular Hexagon | Function to find the diagonal of a regular hexagon ; Side cannot be negative ; Length of the diagonal ; Driver code
function hexDiagonal ( a ) { if ( a < 0 ) return - 1 ; var d = 1.73 * a ; return d ; } var a = 9 ; document . write ( hexDiagonal ( a ) ) ;
Area of Reuleaux Triangle | Function to find the Area of the Reuleaux triangle ; Side cannot be negative ; Area of the Reuleaux triangle ; Driver code
function ReuleauxArea ( a ) { if ( a < 0 ) return - 1 ; var A = 0.70477 * Math . pow ( a , 2 ) ; return A ; } var a = 6 ; document . write ( ReuleauxArea ( a ) ) ;
Largest Square that can be inscribed within a hexagon | Function to find the area of the square ; Side cannot be negative ; Area of the square ; Driver code
function squareArea ( a ) { if ( a < 0 ) return - 1 ; var area = ( Math . pow ( 1.268 , 2 ) * Math . pow ( a , 2 ) ) ; return area ; } var a = 6 ; document . write ( squareArea ( a ) . toFixed ( 5 ) ) ;
Volume of cube using its space diagonal | Function to calculate Volume ; Formula to find Volume ; space diagonal of Cube
function CubeVolume ( d ) { let Volume ; Volume = ( Math . sqrt ( 3 ) * Math . pow ( d , 3 ) ) / 9 ; return Volume ; } let d = 5 ; document . write ( " " + CubeVolume ( d ) . toFixed ( 4 ) ) ;
Perimeter and Area of Varignon 's Parallelogram | Function to find the perimeter ; Function to find the area ; Driver code
function per ( a , b ) { return ( a + b ) ; } function area ( s ) { return ( s / 2 ) ; } var a = 7 , b = 8 , s = 10 ; document . write ( per ( a , b ) ) ; document . write ( area ( s ) ) ;
Area of a leaf inside a square | Javascript program to find the area of leaf inside a square ; Function to find area of leaf ; Driver code
const PI = 3.14159265 ; function area_leaf ( a ) { return ( a * a * ( PI / 2 - 1 ) ) ; } let a = 7 ; document . write ( Math . round ( area_leaf ( a ) ) ) ;
Length of rope tied around three equal circles touching each other | Javascript program to find the length of rope ; Function to find the length of rope ; Driver code
const PI = 3.14159265 ; function length_rope ( r ) { return ( ( 2 * PI * r ) + 6 * r ) ; } let r = 7 ; document . write ( Math . ceil ( length_rope ( r ) ) ) ;
Area of Incircle of a Right Angled Triangle | javascript code to find the area of inscribed circle of right angled triangle ; Function to find the area of inscribed circle ; Driver code
let PI = 3.14159265 ; function area_inscribed ( P , B , H ) { return ( ( P + B - H ) * ( P + B - H ) * ( PI / 4 ) ) ; } var P = 3 , B = 4 , H = 5 ; document . write ( area_inscribed ( P , B , H ) . toFixed ( 6 ) ) ;
Area of Circumcircle of a Right Angled Triangle | javascript code to find the area of circumscribed circle of right angled triangle ; Function to find the area of circumscribed circle ; Driver code
let PI = 3.14159265 ; function area_cicumscribed ( c ) { return ( c * c * ( PI / 4 ) ) ; } var c = 8.0 ; document . write ( area_cicumscribed ( c ) . toFixed ( 6 ) ) ;
Largest right circular cylinder that can be inscribed within a cone | Function to find the biggest right circular cylinder ; radius and height cannot be negative ; radius of right circular cylinder ; height of right circular cylinder ; volume of right circular cylinder ; Driver code
function cyl ( r , h ) { if ( r < 0 && h < 0 ) return - 1 ; var R = ( 2 * r ) / 3 ; var H = ( 2 * h ) / 3 ; var V = 3.14 * Math . pow ( R , 2 ) * H ; return V ; } var r = 4 , h = 8 ; document . write ( cyl ( r , h ) . toFixed ( 5 ) ) ;
Largest cube that can be inscribed within a right circular cylinder | Function to find the volume of the cube ; height and radius cannot be negative ; volume of the cube ; Driver code
function cube ( h , r ) { if ( h < 0 && r < 0 ) return - 1 ; var a = Math . pow ( h , 3 ) ; return a ; } var h = 5 , r = 4 ; document . write ( cube ( h , r ) ) ;
Volume of biggest sphere within a right circular cylinder | Function to find the biggest sphere ; radius and height cannot be negative ; radius of sphere ; Driver code
function sph ( r , h ) { if ( r < 0 && h < 0 ) return - 1 ; var R = r ; return R ; } var r = 4 , h = 8 ; document . write ( sph ( r , h ) ) ;
Volume of largest right circular cylinder within a Sphere | Function to find the biggest right circular cylinder ; radius cannot be negative ; volume of cylinder ; Driver code
function cyl ( R ) { if ( R < 0 ) return - 1 ; var V = ( ( 2 * 3.14 * Math . pow ( R , 3 ) ) / ( 3 * Math . sqrt ( 3 ) ) ) ; return V ; } var R = 4 ; document . write ( cyl ( R ) . toFixed ( 4 ) ) ;
Longest rod that can be inserted within a right circular cylinder | Function to find the side of the cube ; height and radius cannot be negative ; length of rod ; Driver code
function rod ( h , r ) { if ( h < 0 && r < 0 ) return - 1 ; var l = ( Math . sqrt ( Math . pow ( h , 2 ) + 4 * Math . pow ( r , 2 ) ) ) ; return l ; } var h = 4 ; var r = 1.5 ; document . write ( rod ( h , r ) ) ;
Largest cube that can be inscribed within a right circular cone | Function to find the side of the cube ; height and radius cannot be negative ; side of the cube ; Driver code
function cube ( h , r ) { if ( h < 0 && r < 0 ) return - 1 ; var a = ( h * r * Math . sqrt ( 2 ) ) / ( h + Math . sqrt ( 2 ) * r ) ; return a ; } var h = 5 , r = 6 ; document . write ( cube ( h , r ) . toFixed ( 5 ) ) ;
Largest right circular cone that can be inscribed within a sphere | Function to find the radius of the cone ; radius cannot be negative ; radius of the cone ; Function to find the height of the cone ; side cannot be negative ; height of the cone ; Driver code
function coner ( R ) { if ( R < 0 ) return - 1 ; var r = ( 2 * Math . sqrt ( 2 ) * R ) / 3 ; return r ; } function coneh ( R ) { if ( R < 0 ) return - 1 ; var h = ( 4 * R ) / 3 ; return h ; } var R = 10 ; document . write ( " " + coner ( R ) . toFixed ( 5 ) + " " + " " + coneh ( R ) . toFixed ( 5 ) ) ;
Largest cone that can be inscribed within a cube | Function to find the radius of the cone ; side cannot be negative ; radius of the cone ; Function to find the height of the cone ; side cannot be negative ; height of the cone ; Driver code
function coneRadius ( a ) { if ( a < 0 ) return - 1 ; var r = ( a / Math . sqrt ( 2 ) ) ; return r ; } function coneHeight ( a ) { if ( a < 0 ) return - 1 ; var h = a ; return h ; } var a = 6 ; document . write ( " " + coneRadius ( a ) . toFixed ( 5 ) + " " + " " + coneHeight ( a ) ) ;
Largest cube that can be inscribed within the sphere | Function to find the side of the cube ; radius cannot be negative ; side of the cube ; Driver code
function largestCube ( r ) { if ( r < 0 ) return - 1 ; var a = ( 2 * r ) / Math . sqrt ( 3 ) ; return a ; } var r = 5 ; document . write ( largestCube ( r ) . toFixed ( 5 ) ) ;
Largest sphere that can be inscribed inside a cube | Function to find the radius of the sphere ; side cannot be negative ; radius of the sphere ; Driver code
function sphere ( a ) { if ( a < 0 ) return - 1 ; var r = a / 2 ; return r ; } var a = 5 ; document . write ( sphere ( a ) ) ;
Minimum Cuts can be made in the Chessboard such that it is not divided into 2 parts | function that calculates the maximum no . of cuts ; Driver Code ; Calling function .
function numberOfCuts ( M , N ) { var result = 0 ; result = ( M - 1 ) * ( N - 1 ) ; return result ; } var M = 4 , N = 4 ; var Cuts = numberOfCuts ( M , N ) ; document . write ( " " + Cuts ) ;
Find maximum volume of a cuboid from the given perimeter and area | function to return maximum volume ; calculate length ; calculate volume ; return result ; Driver code ; Function call
function maxVol ( P , A ) { let l = ( P - Math . sqrt ( P * P - 24 * A ) ) / 12 ; let V = l * ( A / 2.0 - l * ( P / 4.0 - l ) ) ; return V ; } let P = 20 , A = 16 ; document . write ( maxVol ( P , A ) . toFixed ( 5 ) ) ;
Program to calculate area and perimeter of a rhombus whose diagonals are given | calculate area and perimeter of a rhombus ; Driver code
function rhombusAreaPeri ( d1 , d2 ) { let area , perimeter ; area = Math . floor ( ( d1 * d2 ) / 2 ) ; perimeter = Math . floor ( 2 * Math . sqrt ( Math . pow ( d1 , 2 ) + Math . pow ( d2 , 2 ) ) ) ; document . write ( " " + d1 + " " + d2 + " " + area + " " + " " ) ; document . write ( " " + d1 + " " + d2 + " " + perimeter + " " + " " ) ; } let d1 = 2 , d2 = 4 ; rhombusAreaPeri ( d1 , d2 ) ;
Area of decagon inscribed within the circle | Function to find the area of the decagon ; radius cannot be negative ; area of the decagon ; Driver code
function area ( r ) { if ( r < 0 ) return - 1 ; var area = ( 5 * Math . pow ( r , 2 ) * ( 3 - Math . sqrt ( 5 ) ) * ( Math . sqrt ( 5 ) + ( ( 2 * Math . sqrt ( 5 ) ) ) ) / 4 ) ; return area ; } var r = 8 ; document . write ( area ( r ) . toFixed ( 3 ) ) ;
Maximum area of rectangle possible with given perimeter | Function to find max area ; return area ; Driver code
function maxArea ( perimeter ) { let length = Math . ceil ( perimeter / 4 ) ; let breadth = Math . floor ( perimeter / 4 ) ; return length * breadth ; } let n = 38 ; document . write ( " " + maxArea ( n ) ) ;
Find the foot of perpendicular of a point in a 3 D plane | Function to find foot of perpendicular ; Driver Code ; function call
function foot ( a , b , c , d , x1 , y1 , z1 ) { var k = ( - a * x1 - b * y1 - c * z1 - d ) / ( a * a + b * b + c * c ) ; var x2 = a * k + x1 ; var y2 = b * k + y1 ; var z2 = c * k + z1 ; document . write ( " " + x2 . toFixed ( 1 ) + " " ) ; document . write ( " " + y2 . toFixed ( 1 ) + " " ) ; document . write ( " " + z2 . toFixed ( 1 ) + " " ) ; } var a = 1 ; var b = - 2 ; var c = 0 ; var d = 0 ; var x1 = - 1 ; var y1 = 3 ; var z1 = 4 ; foot ( a , b , c , d , x1 , y1 , z1 ) ;
Equation of parabola from its focus and directrix | Function to find equation of parabola . ; Driver Code
function equation_parabola ( x1 , y1 , a , b , c ) { var t = a * a + b * b ; var a1 = t - ( a * a ) ; var b1 = t - ( b * b ) ; var c1 = ( - 2 * t * x1 ) - ( 2 * c * a ) ; var d1 = ( - 2 * t * y1 ) - ( 2 * c * b ) ; var e1 = - 2 * a * b ; var f1 = ( - c * c ) + ( t * x1 * x1 ) + ( t * y1 * y1 ) ; document . write ( " " + a1 + " " + b1 + " " + c1 + " " + d1 + " " + e1 + " " + f1 + " " ) ; } var x1 = 0 ; var y1 = 0 ; var a = 3 ; var b = - 4 ; var c = 2 ; equation_parabola ( x1 , y1 , a , b , c ) ;
Minimum squares to evenly cut a rectangle | Javascript program to find minimum number of squares to make a given rectangle . ; if we take gcd ( l , w ) , this will be largest possible side for square , hence minimum number of square . ; Number of squares . ; Driver code
function __gcd ( a , b ) { if ( b == 0 ) return a ; return __gcd ( b , a % b ) ; } function countRectangles ( l , w ) { let squareSide = __gcd ( l , w ) ; return parseInt ( ( l * w ) / ( squareSide * squareSide ) ) ; } let l = 4 , w = 6 ; document . write ( countRectangles ( l , w ) ) ;
Equation of circle from center and radius | Function to find the equation of circle ; Printing result ; Driver code
function circle_equation ( x1 , y1 , r ) { let a = - 2 * x1 ; let b = - 2 * y1 ; let c = ( r * r ) - ( x1 * x1 ) - ( y1 * y1 ) ; document . write ( " " + a + " " ) ; document . write ( " " + b + " " ) ; document . write ( c + " " ) ; } let x1 = 2 ; let y1 = - 3 ; let r = 8 ; circle_equation ( x1 , y1 , r ) ;
Program to find the Area and Perimeter of a Semicircle | Function for calculating the area ; Formula for finding the area ; Function for calculating the perimeter ; Formula for finding the perimeter ; Get the radius ; Find the area ; Find the perimeter
function area ( r ) { return ( ( 0.5 ) * ( 3.14 ) * ( r * r ) ) ; } function perimeter ( r ) { return ( ( 3.14 ) * ( r ) ) ; } var r = 10 ; document . write ( " " + area ( r ) . toFixed ( 6 ) + " " ) ; document . write ( " " + perimeter ( r ) . toFixed ( 6 ) + " " ) ;