Found 185 Articles for Haskell

Haskell program to check armstrong number between two integers

Potti Chandra Sekhar sai
Updated on 27-Oct-2022 07:20:08

242 Views

This tutorial will discuss writing a program to display Armstrong numbers between two Integers. Haskell is a Functional, Declarative, and Strongly Typed Language. Computations in Haskell are Mathematical Functions. Armstrong Number is a number that is equal to the sum of its raised to the power of the number of digits in that number. Example 9474 is an Armstrong Number because 9474 = 9^4 + 4^7 + 7^4 + 4^4. 153 is an Armstrong Number because 153 = 1^3 + 5^3 + 3^3. Algorithm steps Implement a function to check whether a number is an Armstrong number. Implement a ... Read More

Haskell program to add binary strings

Potti Chandra Sekhar sai
Updated on 27-Oct-2022 05:36:16

305 Views

This tutorial will discuss writing a program to add binary Strings in Haskell Programming Language. The computations in Haskell are Mathematical functions. Binary Strings represent a number in binary form but with String data type. Example: 5 is described as “0101”. Algorithmic steps Take Binary Strings as input. Implement the logic for adding binary Strings Print the resultant Binary String. Program to add Binary Strings We break the program into simpler functions Syntax Importing essential Packages/Modules import Data.Char Data.Char is a useful module for having functions to type cast Character to Integer and Integer to ... Read More

Haskell program to display all prime numbers from 1 to n

Potti Chandra Sekhar sai
Updated on 27-Oct-2022 05:32:09

1K+ Views

This tutorial will discuss writing a program to display all prime numbers from 1 to N in Haskell Programming Language. Haskell is a declarative, strongly typed, and functional language. The computations in Haskell are mathematical functions. A prime number is one that must have two positive factors 1 and the number itself. Example 2, 3, 5, 7, .. Note 1 is not a prime number because it has only one factor. Algorithm steps Implementing a function to check whether a number is prime. Implementing a function to generate all prime in a range. Display the prime numbers. Program to ... Read More

Haskell Program to Check whether the input number is a Neon Number

Potti Chandra Sekhar sai
Updated on 27-Oct-2022 05:30:03

245 Views

This tutorial will discuss writing a program to check whether the input number is a Neon Number in Haskell Programming Language. The computations in Haskell are mathematical functions. A neon Number is a number that satisfies the property: number is equal to the sum of the digits of its square. Example: 9 is a neon number because the sum of the digits of its square “81” (8+1) is equal to the number 9. In this Tutorial, we will discuss Program to check whether the number is a Neon number. Program to print neon numbers in a range in an ... Read More

Haskell program to multiply two floating point numbers

Akhil Sharma
Updated on 19-Jan-2023 15:08:46

695 Views

This tutorial will help us in multiplying two floating point numbers. The multiplication is simply an arithmetic mathematical operation. In Haskell, floating point numbers are represented as values of the Float or Double type. You can use the (*) operator or the multiply() function to multiply two floating point numbers in Haskell. Alternatively, we can also use (/) operator to multiply two floating point numbers by dividing 1 by the reciprocal of the second number. Method 1: Using Multiply Function This method uses multiply() function to multiply two floating point numbers. The function is defined before the main function, as ... Read More

Advertisements