Prime Number Program In Tcl

Check given number is prime number or not using c program Definition of prime number: A natural number greater than one has not any other divisors except 1 and itself.

>>>>I am trying to write a program that will figure out if a number is prime >>or not. Currently this is the code that I have: >>[code cut] >>Hi Andrade1, >>As in your other previous homework programs, you seem to have some trouble >with control flow. Have you considered talking with your professor or >teaching assistant about this? >>>>import math >>>>def main(): >>number=input('Please enter a positive whole number greater than 2: >>') >>for value in range(2, number-math.sqrt): >>if number% value == 0: >>print number, 'is not prime' >>exit >>print number, 'is prime' >>>>main() >>>>my problem is that the output prints both statements whether the number >>is prime or not. >>>The block of code: >>###### >for value in range(2, number-math.sqrt): >if number% value == 0: >print number, 'is not prime' >exit >###### >>has two issues.

What is 'exit'? Instead of exit I can use break so that the loop will stop executing >2. What is 'number - math.sqrt'? For math.sqrt I could use math.sqrt(n) so that it would take the sqrt of n which is entered in by the user However for the output I am still receiving enter a number greater than 2: 49 49 is prime 49 is prime 49 is prime 49 is prime 49 is prime 49 is not prime >Instead of 'exit', you may be looking for the 'return' statement instead. Manual Electrotehnica Pdf. >>>Good luck to you. >>Kayo Dot Gamma Knife Rar. Minecraft Game Rules. Recent Messages in this Thread.

How To Program Tcl RemotePrime Number Program In Python