bsc

Comprehensive codebase and cou...
Log | Files | Refs | README | LICENSE

P042.c (1259B)


      1 /*
      2  * Author  : Amit Dutta <amitdutta4255@gmail.com>
      3  * Date    : 12 Dec 2025
      4  * Repo    : https://github.com/notamitgamer/bsc
      5  * License : MIT License (See the LICENSE file for details)
      6  */
      7 
      8 /* Write a program to accept a number and check whether the number
      9 is twisted prime or not. */
     10 
     11 #include <stdio.h>
     12 #include <math.h>
     13 
     14 int main()
     15 {
     16     int n, t, i, r, rev, prime = 1;
     17     printf("Enter the number : ");
     18     scanf("%d", &n);
     19     for (i = 2; i <= (int)sqrt(n); i++)
     20     {
     21         if (n % i == 0)
     22         {
     23             prime = 0;
     24             break;
     25         }
     26     }
     27     if (prime)
     28     {
     29         printf("%d is a prime number.", n);
     30         t = n;
     31         rev = 0;
     32         prime = 1;
     33         while (t > 0)
     34         {
     35             r = t % 10;
     36             rev = rev * 10 + r;
     37             t = t / 10;
     38         }
     39         for (i = 2; i <= (int)sqrt(rev); i++)
     40         {
     41             if (rev % i == 0)
     42             {
     43                 prime = 0;
     44                 break;
     45             }
     46         }
     47         if (prime)
     48         {
     49             printf("\n%d and %d are prime numbers.. TWISTED PRIME", n, rev);
     50         }
     51         else
     52         {
     53             printf("\n%d is non prime", rev);
     54         }
     55     }
     56     else
     57     {
     58         printf("\n%d is non prime.", n);
     59     }
     60     return 0;
     61 }
© notamitgamer • Site Built: 2026-07-21 13:58:23 UTC • git-mirror commit: 1037f62 [view raw info]
Originally created with stagit • modified by notamitgamer
Forked from github.com/notamitgamer/git-mirror