Check if prime or not
1) int i,m,n, Flag = 0
2) n = user input
3) m = n/2 or Sqrt(n)
4) if n <=1 then not prime
5) loop i = 2 and i<=m
6) if (n%i==0) , Not prime, Flag = 1, break loop
7) if flag = 0, Number is prime
Check if prime or not between two numbers;
1) input start and end
2) Run loop between 2
3) create a function isPrime(i) and print if prime.
Isprime(i) algorithm
1) int i,m,n
2) n = user input
3) m = n/2 or Sqrt(n)
4) if n <=1 then not prime
5) loop i = 2 and i<=m
6) if (n%!=0) , Not prime, Flag = 1, break loop
7) if flag = 0, prime.
Find the factors of numbers
1) Get the number - should not be prime
2) loop fromi = 2 to number/2
3) if number%i = 0, then print i
Factorial of Number
1) get the number
2) int fact = 1
3) for i = i to number
4) fact = fact * i print fact
1) int i,m,n, Flag = 0
2) n = user input
3) m = n/2 or Sqrt(n)
4) if n <=1 then not prime
5) loop i = 2 and i<=m
6) if (n%i==0) , Not prime, Flag = 1, break loop
7) if flag = 0, Number is prime
Check if prime or not between two numbers;
1) input start and end
2) Run loop between 2
3) create a function isPrime(i) and print if prime.
Isprime(i) algorithm
1) int i,m,n
2) n = user input
3) m = n/2 or Sqrt(n)
4) if n <=1 then not prime
5) loop i = 2 and i<=m
6) if (n%!=0) , Not prime, Flag = 1, break loop
7) if flag = 0, prime.
Find the factors of numbers
1) Get the number - should not be prime
2) loop fromi = 2 to number/2
3) if number%i = 0, then print i
Factorial of Number
1) get the number
2) int fact = 1
3) for i = i to number
4) fact = fact * i print fact