Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 719957
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T05:42:12+00:00 2026-05-14T05:42:12+00:00

i would like to find a formula describing this series. i need to set

  • 0

i would like to find a formula describing this series.
i need to set a boolean depending on a positive integer.
it’s pretty simple but i am stuck and feel a bit stupid.

0 false
1 true
2 true
3 false
4 false
5 true
6 true
7 false
8 false
9 true
10 true
11 false
12 false
...

so the flag changes at every odd number

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T05:42:13+00:00Added an answer on May 14, 2026 at 5:42 am

    Well, for the flag changing at every odd number, it looks like your boolean should be true if and only if (n+3)%4 <= 1, where % is the modulo operator:

     n   (n+3)%4   Boolean
    --   -------   -------
     0      3       false
     1      0       true
     2      1       true
     3      2       false
     4      3       false
     5      0       true
     6      1       true
     7      2       false
     8      3       false
     9      0       true
    10      1       true
    11      2       false
    12      3       false
    ::      :       :  :
    

    I’ve deliberately added three instead of subtracting one, since some languages have different ideas of what the modulo operator should do for negative numbers. And keep in mind that this is language-agnostic. If you’re specifically looking for a C or C-like language solution, see the excellent answer here from Christoffer Hammarström ((n + 1) & 2 just in case it ever disappears) – this is far more succinct in those particular languages.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to find each integer coordinate point between 2 set of coordinate
I would like to find c and t coefficients in simple result=x*t+c formula for
I would like to find the distance of every pixel coordinate in an image
I would like to find out which version of an executable the CMD shell
I would like to find a way to store multiple addresses for one subject
I would like to find out is as3 is doing is doing anything in
I would like to find an API like Apache Commons that will easily and
I would like to find a way to see what happens while my XAML
I would like to find the values of some of windows API constants, such
I would like to find a way to compile and package our iPhone application

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.