Check whether the given number is nude number or not

Here given code implementation process.

// C program for 
// Check whether the given number is nude number or not
#include <stdio.h>

void isNudeNo(int number)
{
	// Define some auxiliary variables
	// result indicator
	int status = 1;
	// Use to store number digit
	int digit = 0;
	// Get given number
	int n = number;
	// Check if number is divisible by each of its digits or not number
	while (n != 0 && status == 1)
	{
		// Get last digit of n
		digit = n % 10;
		// Check if digit is divisible by given number or not
		if (digit == 0 || (number % digit) != 0)
		{
			// When number is not divisible by digit
			// Or digit is 0
			status = 0;
		}
		else
		{
			// Remove last digit
			n = n / 10;
		}
	}
	if (status == 1)
	{
		printf(" Number %d is nude number\n", number);
	}
	else
	{
		printf(" Number %d is not nude number\n", number);
	}
}
int main(int argc, char
	const *argv[])
{
	// Test Cases
	isNudeNo(126);
	isNudeNo(361);
	isNudeNo(2120);
	isNudeNo(48);
	isNudeNo(1115);
	return 0;
}

input

 Number 126 is nude number
 Number 361 is not nude number
 Number 2120 is not nude number
 Number 48 is nude number
 Number 1115 is nude number
/*
  Java Program for
  Check whether the given number is nude number or not
*/
public class NudeNumber
{
	public void isNudeNo(int number)
	{
		// Define some auxiliary variables
		// result indicator
		boolean status = true;
		// Use to store number digit
		int digit = 0;
		// Get given number
		int n = number;
		// Check if number is divisible by each of its digits or not number
		while (n != 0 && status)
		{
			// Get last digit of n
			digit = n % 10;
			// Check if digit is divisible by given number or not
			if (digit == 0 || (number % digit) != 0)
			{
				// When number is not divisible by digit
				// Or digit is 0
				status = false;
			}
			else
			{
				// Remove last digit
				n = n / 10;
			}
		}
		if (status)
		{
			System.out.println(" Number " + number + " is nude number");
		}
		else
		{
			System.out.println(" Number " + number + " is not nude number");
		}
	}
	public static void main(String[] args)
	{
		NudeNumber task = new NudeNumber();
		// Test Cases
		task.isNudeNo(126);
		task.isNudeNo(361);
		task.isNudeNo(2120);
		task.isNudeNo(48);
		task.isNudeNo(1115);
	}
}

input

 Number 126 is nude number
 Number 361 is not nude number
 Number 2120 is not nude number
 Number 48 is nude number
 Number 1115 is nude number
// Include header file
#include <iostream>

using namespace std;
/*
  C++ Program for
  Check whether the given number is nude number or not
*/
class NudeNumber
{
	public: void isNudeNo(int number)
	{
		// Define some auxiliary variables
		// result indicator
		bool status = true;
		// Use to store number digit
		int digit = 0;
		// Get given number
		int n = number;
		// Check if number is divisible by each of its digits or not number
		while (n != 0 && status)
		{
			// Get last digit of n
			digit = n % 10;
			// Check if digit is divisible by given number or not
			if (digit == 0 || (number % digit) != 0)
			{
				// When number is not divisible by digit
				// Or digit is 0
				status = false;
			}
			else
			{
				// Remove last digit
				n = n / 10;
			}
		}
		if (status)
		{
			cout << " Number " << number << " is nude number" << endl;
		}
		else
		{
			cout << " Number " << number << " is not nude number" << endl;
		}
	}
};
int main()
{
	NudeNumber *task = new NudeNumber();
	// Test Cases
	task->isNudeNo(126);
	task->isNudeNo(361);
	task->isNudeNo(2120);
	task->isNudeNo(48);
	task->isNudeNo(1115);
	return 0;
}

input

 Number 126 is nude number
 Number 361 is not nude number
 Number 2120 is not nude number
 Number 48 is nude number
 Number 1115 is nude number
// Include namespace system
using System;
/*
  Csharp Program for
  Check whether the given number is nude number or not
*/
public class NudeNumber
{
	public void isNudeNo(int number)
	{
		// Define some auxiliary variables
		// result indicator
		Boolean status = true;
		// Use to store number digit
		int digit = 0;
		// Get given number
		int n = number;
		// Check if number is divisible by each of its digits or not number
		while (n != 0 && status)
		{
			// Get last digit of n
			digit = n % 10;
			// Check if digit is divisible by given number or not
			if (digit == 0 || (number % digit) != 0)
			{
				// When number is not divisible by digit
				// Or digit is 0
				status = false;
			}
			else
			{
				// Remove last digit
				n = n / 10;
			}
		}
		if (status)
		{
			Console.WriteLine(" Number " + number + " is nude number");
		}
		else
		{
			Console.WriteLine(" Number " + number + " is not nude number");
		}
	}
	public static void Main(String[] args)
	{
		NudeNumber task = new NudeNumber();
		// Test Cases
		task.isNudeNo(126);
		task.isNudeNo(361);
		task.isNudeNo(2120);
		task.isNudeNo(48);
		task.isNudeNo(1115);
	}
}

input

 Number 126 is nude number
 Number 361 is not nude number
 Number 2120 is not nude number
 Number 48 is nude number
 Number 1115 is nude number
<?php
/*
  Php Program for
  Check whether the given number is nude number or not
*/
class NudeNumber
{
	public	function isNudeNo($number)
	{
		// Define some auxiliary variables
		// result indicator
		$status = true;
		// Use to store number digit
		$digit = 0;
		// Get given number
		$n = $number;
		// Check if number is divisible by each of its digits or not number
		while ($n != 0 && $status)
		{
			// Get last digit of n
			$digit = $n % 10;
			// Check if digit is divisible by given number or not
			if ($digit == 0 || ($number % $digit) != 0)
			{
				// When number is not divisible by digit
				// Or digit is 0
				$status = false;
			}
			else
			{
				// Remove last digit
				$n = (int)($n / 10);
			}
		}
		if ($status)
		{
			echo " Number ".$number.
			" is nude number".
			"\n";
		}
		else
		{
			echo " Number ".$number.
			" is not nude number".
			"\n";
		}
	}
}

function main()
{
	$task = new NudeNumber();
	// Test Cases
	$task->isNudeNo(126);
	$task->isNudeNo(361);
	$task->isNudeNo(2120);
	$task->isNudeNo(48);
	$task->isNudeNo(1115);
}
main();

input

 Number 126 is nude number
 Number 361 is not nude number
 Number 2120 is not nude number
 Number 48 is nude number
 Number 1115 is nude number
/*
  Node JS Program for
  Check whether the given number is nude number or not
*/
class NudeNumber
{
	isNudeNo(number)
	{
		// Define some auxiliary variables
		// result indicator
		var status = true;
		// Use to store number digit
		var digit = 0;
		// Get given number
		var n = number;
		// Check if number is divisible by each of its digits or not number
		while (n != 0 && status)
		{
			// Get last digit of n
			digit = n % 10;
			// Check if digit is divisible by given number or not
			if (digit == 0 || (number % digit) != 0)
			{
				// When number is not divisible by digit
				// Or digit is 0
				status = false;
			}
			else
			{
				// Remove last digit
				n = parseInt(n / 10);
			}
		}
		if (status)
		{
			console.log(" Number " + number + " is nude number");
		}
		else
		{
			console.log(" Number " + number + " is not nude number");
		}
	}
}

function main()
{
	var task = new NudeNumber();
	// Test Cases
	task.isNudeNo(126);
	task.isNudeNo(361);
	task.isNudeNo(2120);
	task.isNudeNo(48);
	task.isNudeNo(1115);
}
main();

input

 Number 126 is nude number
 Number 361 is not nude number
 Number 2120 is not nude number
 Number 48 is nude number
 Number 1115 is nude number
#  Python 3 Program for
#  Check whether the given number is nude number or not
class NudeNumber :
	def isNudeNo(self, number) :
		status = True
		digit = 0
		n = number
		#  Check if number is divisible by each of its digits or not number
		while (n != 0 and status) :
			#  Get last digit of n
			digit = n % 10
			#  Check if digit is divisible by given number or not
			if (digit == 0 or(number % digit) != 0) :
				#  When number is not divisible by digit
				#  Or digit is 0
				status = False
			else :
				#  Remove last digit
				n = int(n / 10)
			
		
		if (status) :
			print(" Number ", number ," is nude number")
		else :
			print(" Number ", number ," is not nude number")
		
	

def main() :
	task = NudeNumber()
	#  Test Cases
	task.isNudeNo(126)
	task.isNudeNo(361)
	task.isNudeNo(2120)
	task.isNudeNo(48)
	task.isNudeNo(1115)

if __name__ == "__main__": main()

input

 Number  126  is nude number
 Number  361  is not nude number
 Number  2120  is not nude number
 Number  48  is nude number
 Number  1115  is nude number
#  Ruby Program for
#  Check whether the given number is nude number or not
class NudeNumber 
	def isNudeNo(number) 
		#  Define some auxiliary variables
		#  result indicator
		status = true
		#  Use to store number digit
		digit = 0
		#  Get given number
		n = number
		#  Check if number is divisible by each of its digits or not number
		while (n != 0 && status) 
			#  Get last digit of n
			digit = n % 10
			#  Check if digit is divisible by given number or not
			if (digit == 0 || (number % digit) != 0) 
				#  When number is not divisible by digit
				#  Or digit is 0
				status = false
			else 
				#  Remove last digit
				n = n / 10
			end

		end

		if (status) 
			print(" Number ", number ," is nude number", "\n")
		else 
			print(" Number ", number ," is not nude number", "\n")
		end

	end

end

def main() 
	task = NudeNumber.new()
	#  Test Cases
	task.isNudeNo(126)
	task.isNudeNo(361)
	task.isNudeNo(2120)
	task.isNudeNo(48)
	task.isNudeNo(1115)
end

main()

input

 Number 126 is nude number
 Number 361 is not nude number
 Number 2120 is not nude number
 Number 48 is nude number
 Number 1115 is nude number
/*
  Scala Program for
  Check whether the given number is nude number or not
*/
class NudeNumber()
{
	def isNudeNo(number: Int): Unit = {
		// Define some auxiliary variables
		// result indicator
		var status: Boolean = true;
		// Use to store number digit
		var digit: Int = 0;
		// Get given number
		var n: Int = number;
		// Check if number is divisible by each of its digits or not number
		while (n != 0 && status)
		{
			// Get last digit of n
			digit = n % 10;
			// Check if digit is divisible by given number or not
			if (digit == 0 || (number % digit) != 0)
			{
				// When number is not divisible by digit
				// Or digit is 0
				status = false;
			}
			else
			{
				// Remove last digit
				n = (n / 10).toInt;
			}
		}
		if (status)
		{
			println(" Number " + number + " is nude number");
		}
		else
		{
			println(" Number " + number + " is not nude number");
		}
	}
}
object Main
{
	def main(args: Array[String]): Unit = {
		var task: NudeNumber = new NudeNumber();
		// Test Cases
		task.isNudeNo(126);
		task.isNudeNo(361);
		task.isNudeNo(2120);
		task.isNudeNo(48);
		task.isNudeNo(1115);
	}
}

input

 Number 126 is nude number
 Number 361 is not nude number
 Number 2120 is not nude number
 Number 48 is nude number
 Number 1115 is nude number
/*
  Swift 4 Program for
  Check whether the given number is nude number or not
*/
class NudeNumber
{
	func isNudeNo(_ number: Int)
	{
		// Define some auxiliary variables
		// result indicator
		var status: Bool = true;
		// Use to store number digit
		var digit: Int = 0;
		// Get given number
		var n: Int = number;
		// Check if number is divisible by each of its digits or not number
		while (n  != 0 && status)
		{
			// Get last digit of n
			digit = n % 10;
			// Check if digit is divisible by given number or not
			if (digit == 0 || (number % digit)  != 0)
			{
				// When number is not divisible by digit
				// Or digit is 0
				status = false;
			}
			else
			{
				// Remove last digit
				n = n / 10;
			}
		}
		if (status)
		{
			print(" Number ", number ," is nude number");
		}
		else
		{
			print(" Number ", number ," is not nude number");
		}
	}
}
func main()
{
	let task: NudeNumber = NudeNumber();
	// Test Cases
	task.isNudeNo(126);
	task.isNudeNo(361);
	task.isNudeNo(2120);
	task.isNudeNo(48);
	task.isNudeNo(1115);
}
main();

input

 Number  126  is nude number
 Number  361  is not nude number
 Number  2120  is not nude number
 Number  48  is nude number
 Number  1115  is nude number
/*
  Kotlin Program for
  Check whether the given number is nude number or not
*/
class NudeNumber
{
	fun isNudeNo(number: Int): Unit
	{
		// Define some auxiliary variables
		// result indicator
		var status: Boolean = true;
		// Use to store number digit
		var digit: Int ;
		// Get given number
		var n: Int = number;
		while (n != 0 && status)
		{
			// Get last digit of n
			digit = n % 10;
			// Check if digit is divisible by given number or not
			if (digit == 0 || (number % digit) != 0)
			{
				// When number is not divisible by digit
				// Or digit is 0
				status = false;
			}
			else
			{
				// Remove last digit
				n = n / 10;
			}
		}
		if (status)
		{
			println(" Number " + number + " is nude number");
		}
		else
		{
			println(" Number " + number + " is not nude number");
		}
	}
}
fun main(args: Array < String > ): Unit
{
	val task: NudeNumber = NudeNumber();
	// Test Cases
	task.isNudeNo(126);
	task.isNudeNo(361);
	task.isNudeNo(2120);
	task.isNudeNo(48);
	task.isNudeNo(1115);
}

input

 Number 126 is nude number
 Number 361 is not nude number
 Number 2120 is not nude number
 Number 48 is nude number
 Number 1115 is nude 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