Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //https://vk.com/evgenykravchenko0
- ___ ___ ___
- / /\ ___ / /\ / /\
- / /:/_ /__/\ / /:/_ / /:/_
- / /:/ /\ \ \:\ / /:/ /\ / /:/ /\
- / /:/ /:/_ \ \:\ / /:/_/::\ / /:/ /:/_
- /__/:/ /:/ /\ ___ \__\:\ /__/:/__\/\:\ /__/:/ /:/ /\
- \ \:\/:/ /:/ /__/\ | |:| \ \:\ /~~/:/ \ \:\/:/ /:/
- \ \::/ /:/ \ \:\| |:| \ \:\ /:/ \ \::/ /:/
- \ \:\/:/ \ \:\__|:| \ \:\/:/ \ \:\/:/
- \ \::/ \__\::::/ \ \::/ \ \::/
- \__\/ ~~~~ \__\/ \__\/
- ___
- /__/\ ___ ___
- \ \:\ / /\ / /\
- \ \:\ / /:/ / /:/
- _____\__\:\ /__/::\ /__/::\
- /__/::::::::\ \__\/\:\__ \__\/\:\__
- \ \:\~~\~~\/ \ \:\/\ \ \:\/\
- \ \:\ ~~~ \__\::/ \__\::/
- \ \:\ /__/:/ /__/:/
- \ \:\ \__\/ \__\/
- \__\/
- #include <stdio.h>
- #include <conio.h>
- //-— функция —-
- int Simple ( int N )
- {
- for ( int i = 2; i*i <= N; i ++ )
- {
- if ( N % i == 0 )
- return 0;
- }
- return N;
- }
- int main()
- {
- int pali = 0;
- int per;
- int i;
- int N;
- int max = 0;
- printf("Введите значение N : ");
- scanf("%d", &N);
- for (i = 1;i <= N;i++)
- {
- if (Simple(i))
- {
- per = i;
- //pali = 0;
- while( per != 0 )
- {
- pali = pali * 10;
- pali = pali + per % 10;
- per = per / 10;
- }
- if ( i == pali && i > max)
- max = i;
- }
- pali = 0;
- }
- printf("наибольший простой палиндром %d", max);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement