Check if a number is Flavius Number

Here given code implementation process.

// C program
// Check if a number is Flavius Number
#include <stdio.h>

// Check whether given number is Flavius Number or not
void isFlavius(int number)
{
	int status = 1;
	if (number < 1)
	{
		status = 0;
	}
	// Start term
	int n = 2;
	// Get number
	int series = number;
	// Check that number exists in given term
	while (status == 1 && n <= series)
	{
		if (series % n == 0)
		{
			status = 0;
		}
		else
		{
			// Remove nth term
			series = series - (series / n);
		}
		// Visit to next term
		n++;
	}
	if (status == 1)
	{
		printf("\n [%d] Is Flavius Number", number);
	}
	else
	{
		printf("\n [%d] Is Not Flavius Number", number);
	}
}
int main()
{
	//Test case
	isFlavius(3);
	isFlavius(6668);
	isFlavius(49);
	return 0;
}

input

 [3] Is Flavius Number
 [6668] Is Not Flavius Number
 [49] Is Flavius Number
/*
  Java Program 
  Check if a number is Flavius Number
*/
class FlaviusNumber
{
	// Check whether given number is Flavius Number or not
	public void isFlavius(int number)
	{
		boolean status = true;
		if (number < 1)
		{
			status = false;
		}
		// Start term
		int n = 2;
		// Get number
		int series = number;
		// Check that number exists in given term
		while (status == true && n <= series)
		{
			if (series % n == 0)
			{
				status = false;
			}
			else
			{
				// Remove nth term
				series = series - (series / n);
			}
			// Visit to next term
			n++;
		}
		if (status == true)
		{
			System.out.print("\n [" + number + "] Is Flavius Number");
		}
		else
		{
			System.out.print("\n [" + number + "] Is Not Flavius Number");
		}
	}
	public static void main(String[] args)
	{
		FlaviusNumber task = new FlaviusNumber();
		//Test case
		task.isFlavius(3);
		task.isFlavius(6668);
		task.isFlavius(49);
	}
}

input

 [3] Is Flavius Number
 [6668] Is Not Flavius Number
 [49] Is Flavius Number
// Include header file
#include <iostream>

using namespace std;
/*
  C++ Program 
  Check if a number is Flavius Number
*/
class FlaviusNumber
{
	public:
		// Check whether given number is Flavius Number or not
		void isFlavius(int number)
		{
			bool status = true;
			if (number < 1)
			{
				status = false;
			}
			// Start term
			int n = 2;
			// Get number
			int series = number;
			// Check that number exists in given term
			while (status == true && n <= series)
			{
				if (series % n == 0)
				{
					status = false;
				}
				else
				{
					// Remove nth term
					series = series - (series / n);
				}
				// Visit to next term
				n++;
			}
			if (status == true)
			{
				cout << "\n [" << number << "] Is Flavius Number";
			}
			else
			{
				cout << "\n [" << number << "] Is Not Flavius Number";
			}
		}
};
int main()
{
	FlaviusNumber *task = new FlaviusNumber();
	//Test case
	task->isFlavius(3);
	task->isFlavius(6668);
	task->isFlavius(49);
	return 0;
}

input

 [3] Is Flavius Number
 [6668] Is Not Flavius Number
 [49] Is Flavius Number
// Include namespace system
using System;
/*
  Csharp Program 
  Check if a number is Flavius Number
*/
public class FlaviusNumber
{
	// Check whether given number is Flavius Number or not
	public void isFlavius(int number)
	{
		Boolean status = true;
		if (number < 1)
		{
			status = false;
		}
		// Start term
		int n = 2;
		// Get number
		int series = number;
		// Check that number exists in given term
		while (status == true && n <= series)
		{
			if (series % n == 0)
			{
				status = false;
			}
			else
			{
				// Remove nth term
				series = series - (series / n);
			}
			// Visit to next term
			n++;
		}
		if (status == true)
		{
			Console.Write("\n [" + number + "] Is Flavius Number");
		}
		else
		{
			Console.Write("\n [" + number + "] Is Not Flavius Number");
		}
	}
	public static void Main(String[] args)
	{
		FlaviusNumber task = new FlaviusNumber();
		//Test case
		task.isFlavius(3);
		task.isFlavius(6668);
		task.isFlavius(49);
	}
}

input

 [3] Is Flavius Number
 [6668] Is Not Flavius Number
 [49] Is Flavius Number
<?php
/*
  Php Program 
  Check if a number is Flavius Number
*/
class FlaviusNumber
{
	// Check whether given number is Flavius Number or not
	public	function isFlavius($number)
	{
		$status = true;
		if ($number < 1)
		{
			$status = false;
		}
		// Start term
		$n = 2;
		// Get number
		$series = $number;
		// Check that number exists in given term
		while ($status == true && $n <= $series)
		{
			if ($series % $n == 0)
			{
				$status = false;
			}
			else
			{
				// Remove nth term
				$series = $series - ((int)($series / $n));
			}
			// Visit to next term
			$n++;
		}
		if ($status == true)
		{
			echo "\n [".$number.
			"] Is Flavius Number";
		}
		else
		{
			echo "\n [".$number.
			"] Is Not Flavius Number";
		}
	}
}

function main()
{
	$task = new FlaviusNumber();
	//Test case
	$task->isFlavius(3);
	$task->isFlavius(6668);
	$task->isFlavius(49);
}
main();

input

 [3] Is Flavius Number
 [6668] Is Not Flavius Number
 [49] Is Flavius Number
/*
  Node JS Program 
  Check if a number is Flavius Number
*/
class FlaviusNumber
{
	// Check whether given number is Flavius Number or not
	isFlavius(number)
	{
		var status = true;
		if (number < 1)
		{
			status = false;
		}
		// Start term
		var n = 2;
		// Get number
		var series = number;
		// Check that number exists in given term
		while (status == true && n <= series)
		{
			if (series % n == 0)
			{
				status = false;
			}
			else
			{
				// Remove nth term
				series = series - (parseInt(series / n));
			}
			// Visit to next term
			n++;
		}
		if (status == true)
		{
			process.stdout.write("\n [" + number + "] Is Flavius Number");
		}
		else
		{
			process.stdout.write("\n [" + number + "] Is Not Flavius Number");
		}
	}
}

function main()
{
	var task = new FlaviusNumber();
	//Test case
	task.isFlavius(3);
	task.isFlavius(6668);
	task.isFlavius(49);
}
main();

input

 [3] Is Flavius Number
 [6668] Is Not Flavius Number
 [49] Is Flavius Number
# Python 3 Program
# Check if a number is Flavius Number
class FlaviusNumber :
	# Check whether given number is Flavius Number or not
	def isFlavius(self, number) :
		status = True
		if (number < 1) :
			status = False
		
		n = 2
		series = number
		# Check that number exists in given term
		while (status == True and n <= series) :
			if (series % n == 0) :
				status = False
			else :
				# Remove nth term
				series = series - (int(series / n))
			
			# Visit to next term
			n += 1
		
		if (status == True) :
			print("\n [", number ,"] Is Flavius Number", end = "")
		else :
			print("\n [", number ,"] Is Not Flavius Number", end = "")
		
	

def main() :
	task = FlaviusNumber()
	# Test case
	task.isFlavius(3)
	task.isFlavius(6668)
	task.isFlavius(49)

if __name__ == "__main__": main()

input

 [ 3 ] Is Flavius Number
 [ 6668 ] Is Not Flavius Number
 [ 49 ] Is Flavius Number
# Ruby Program
# Check if a number is Flavius Number
class FlaviusNumber 
	# Check whether given number is Flavius Number or not
	def isFlavius(number) 
		status = true
		if (number < 1) 
			status = false
		end

		# Start term
		n = 2
		# Get number
		series = number
		# Check that number exists in given term
		while (status == true && n <= series) 
			if (series % n == 0) 
				status = false
			else 
				# Remove nth term
				series = series - (series / n)
			end

			# Visit to next term
			n += 1
		end

		if (status == true) 
			print("\n [", number ,"] Is Flavius Number")
		else 
			print("\n [", number ,"] Is Not Flavius Number")
		end

	end

end

def main() 
	task = FlaviusNumber.new()
	# Test case
	task.isFlavius(3)
	task.isFlavius(6668)
	task.isFlavius(49)
end

main()

input

 [3] Is Flavius Number
 [6668] Is Not Flavius Number
 [49] Is Flavius Number
/*
  Scala Program 
  Check if a number is Flavius Number
*/
class FlaviusNumber()
{
	// Check whether given number is Flavius Number or not
	def isFlavius(number: Int): Unit = {
		var status: Boolean = true;
		if (number < 1)
		{
			status = false;
		}
		// Start term
		var n: Int = 2;
		// Get number
		var series: Int = number;
		// Check that number exists in given term
		while (status == true && n <= series)
		{
			if (series % n == 0)
			{
				status = false;
			}
			else
			{
				// Remove nth term
				series = series - ((series / n).toInt);
			}
			// Visit to next term
			n += 1;
		}
		if (status == true)
		{
			print("\n [" + number + "] Is Flavius Number");
		}
		else
		{
			print("\n [" + number + "] Is Not Flavius Number");
		}
	}
}
object Main
{
	def main(args: Array[String]): Unit = {
		var task: FlaviusNumber = new FlaviusNumber();
		//Test case
		task.isFlavius(3);
		task.isFlavius(6668);
		task.isFlavius(49);
	}
}

input

 [3] Is Flavius Number
 [6668] Is Not Flavius Number
 [49] Is Flavius Number
/*
  Swift 4 Program 
  Check if a number is Flavius Number
*/
class FlaviusNumber
{
	// Check whether given number is Flavius Number or not
	func isFlavius(_ number: Int)
	{
		var status: Bool = true;
		if (number < 1)
		{
			status = false;
		}
		// Start term
		var n: Int = 2;
		// Get number
		var series: Int = number;
		// Check that number exists in given term
		while (status == true && n <= series)
		{
			if (series % n == 0)
			{
				status = false;
			}
			else
			{
				// Remove nth term
				series = series - (series / n);
			}
			// Visit to next term
			n += 1;
		}
		if (status == true)
		{
			print("\n [", number ,"] Is Flavius Number", terminator: "");
		}
		else
		{
			print("\n [", number ,"] Is Not Flavius Number", terminator: "");
		}
	}
}
func main()
{
	let task: FlaviusNumber = FlaviusNumber();
	//Test case
	task.isFlavius(3);
	task.isFlavius(6668);
	task.isFlavius(49);
}
main();

input

 [ 3 ] Is Flavius Number
 [ 6668 ] Is Not Flavius Number
 [ 49 ] Is Flavius Number
/*
  Kotlin Program 
  Check if a number is Flavius Number
*/
class FlaviusNumber
{
	// Check whether given number is Flavius Number or not
	fun isFlavius(number: Int): Unit
	{
		var status: Boolean = true;
		if (number < 1)
		{
			status = false;
		}
		// Start term
		var n: Int = 2;
		// Get number
		var series: Int = number;
		while (status == true && n <= series)
		{
			if (series % n == 0)
			{
				status = false;
			}
			else
			{
				// Remove nth term
				series = series - (series / n);
			}
			// Visit to next term
			n += 1;
		}
		if (status == true)
		{
			print("\n [" + number + "] Is Flavius Number");
		}
		else
		{
			print("\n [" + number + "] Is Not Flavius Number");
		}
	}
}
fun main(args: Array < String > ): Unit
{
	val task: FlaviusNumber = FlaviusNumber();
	//Test case
	task.isFlavius(3);
	task.isFlavius(6668);
	task.isFlavius(49);
}

input

 [3] Is Flavius Number
 [6668] Is Not Flavius Number
 [49] Is Flavius Number


Please share your knowledge to improve code and content standard. Also submit your doubts, and test case. We improve by your feedback. We will try to resolve your query as soon as possible.

New Comment







© 2021, kalkicode.com, All rights reserved