20% Discount Primes

How many five-digit primes have exactly one zero as a digit?

For example, 984 0 7 is one such prime.


The answer is 2017.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

1 solution

Anandhu Raj
Apr 18, 2017

The following C program will find and count all such prime numbers, #include<stdio.h> int checkprime(int); main() { int j=0,flag2,i,k,c; for(k=10000;k<=99999;k++) { c=checkprime(k); if(c==1) { flag2=0; i=k; while(i) { c=i\%10; i=i/10; if(c==0) { flag2++; } } if(flag2==1) { printf("\%d\n",k); j++; } } } printf("\nNo.of such numbers is \%d\n",j); } int checkprime(int a) { int i,flag=0,c; for(i=2;i<=(a/2);i++) { if(a\%i==0) { flag=1; return 0; } } if(flag==0) return 1; }

What is this? :O

Guilherme Dela Corte - 3 years, 8 months ago

Log in to reply

How to write programming language using latex?

Anandhu Raj - 3 years, 6 months ago

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...