Nyoj 480 maid!

Source: Internet
Author: User

Fibonacci again! Time Limit: 1000 MS | memory limit: 65535 kb difficulty: 2
Description
Determine whether the nth Fibonacci number is a prime number. N is an integer f [N] = f [n-1] + F [N-2] (2 <n <30) f [1] = 3, F [2] = 7
Input
Input integer m, 0 <m <30, input-1 indicates end input

Output
If f [m] is a prime number, yes is output; otherwise no is output,
Each row of output occupies one row.
Sample Input
23
Sample output
YesNo



# Include <stdio. h> int f [35] = {0, 3, 7}; int prime (int x) {int K; For (k = 2; k <X; k ++) if (X % K = 0) return 0; return 1 ;}int main () {int I, j; int m; for (I = 3; I <35; I ++) f [I] = f [I-1] + F [I-2]; while (scanf ("% d", & M) & M! =-1) // & M! =-1 and! = Is EOF different? {If (prime (F [m]) printf ("Yes \ n"); else printf ("NO \ n");} return 0 ;}



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.